Skip to content

Commit b942304

Browse files
committed
Refuse to start if we detect libevent 1.[12]
1 parent 39f6eeb commit b942304

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

memcached.c

+27
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,7 @@ static void server_stats(ADD_STAT add_stats, conn *c) {
23742374
APPEND_STAT("uptime", "%u", now);
23752375
APPEND_STAT("time", "%ld", now + (long)process_started);
23762376
APPEND_STAT("version", "%s", VERSION);
2377+
APPEND_STAT("libevent", "%s", event_get_version());
23772378
APPEND_STAT("pointer_size", "%d", (int)(8 * sizeof(void *)));
23782379

23792380
#ifndef WIN32
@@ -4250,6 +4251,28 @@ static int enable_large_pages(void) {
42504251
#endif
42514252
}
42524253

4254+
/**
4255+
* Do basic sanity check of the runtime environment
4256+
* @return true if no errors found, false if we can't use this env
4257+
*/
4258+
static bool sanitycheck(void) {
4259+
/* One of our biggest problems is old and bogus libevents */
4260+
const char *ever = event_get_version();
4261+
if (ever != NULL) {
4262+
if (strncmp(ever, "1.", 2) == 0) {
4263+
/* Require at least 1.3 (that's still a couple of years old) */
4264+
if ((ever[2] == '1' || ever[2] == '2') && !isdigit(ever[3])) {
4265+
fprintf(stderr, "You are using libevent %s.\nPlease upgrade to"
4266+
" a more recent version (1.3 or newer)\n",
4267+
event_get_version());
4268+
return false;
4269+
}
4270+
}
4271+
}
4272+
4273+
return true;
4274+
}
4275+
42534276
int main (int argc, char **argv) {
42544277
int c;
42554278
bool lock_memory = false;
@@ -4271,6 +4294,10 @@ int main (int argc, char **argv) {
42714294
bool tcp_specified = false;
42724295
bool udp_specified = false;
42734296

4297+
if (!sanitycheck()) {
4298+
return EX_OSERR;
4299+
}
4300+
42744301
/* handle SIGINT */
42754302
signal(SIGINT, sig_handler);
42764303

t/binary.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use strict;
44
use warnings;
5-
use Test::More tests => 3361;
5+
use Test::More tests => 3373;
66
use FindBin qw($Bin);
77
use lib "$Bin/lib";
88
use MemcachedTest;

t/stats.t

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ my $sock = $server->sock;
1616
## STAT uptime 13
1717
## STAT time 1259170891
1818
## STAT version 1.4.3
19+
## STAT libevent 1.4.13-stable.
1920
## STAT pointer_size 32
2021
## STAT rusage_user 0.001198
2122
## STAT rusage_system 0.003523
@@ -57,7 +58,7 @@ my $sock = $server->sock;
5758
my $stats = mem_stats($sock);
5859

5960
# Test number of keys
60-
is(scalar(keys(%$stats)), 38, "38 stats values");
61+
is(scalar(keys(%$stats)), 39, "39 stats values");
6162

6263
# Test initial state
6364
foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses

0 commit comments

Comments
 (0)