Skip to content

Commit

Permalink
Refuse to start if we detect libevent 1.[12]
Browse files Browse the repository at this point in the history
  • Loading branch information
trondn committed Sep 14, 2010
1 parent 39f6eeb commit b942304
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
27 changes: 27 additions & 0 deletions memcached.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2374,6 +2374,7 @@ static void server_stats(ADD_STAT add_stats, conn *c) {
APPEND_STAT("uptime", "%u", now); APPEND_STAT("uptime", "%u", now);
APPEND_STAT("time", "%ld", now + (long)process_started); APPEND_STAT("time", "%ld", now + (long)process_started);
APPEND_STAT("version", "%s", VERSION); APPEND_STAT("version", "%s", VERSION);
APPEND_STAT("libevent", "%s", event_get_version());
APPEND_STAT("pointer_size", "%d", (int)(8 * sizeof(void *))); APPEND_STAT("pointer_size", "%d", (int)(8 * sizeof(void *)));


#ifndef WIN32 #ifndef WIN32
Expand Down Expand Up @@ -4250,6 +4251,28 @@ static int enable_large_pages(void) {
#endif #endif
} }


/**
* Do basic sanity check of the runtime environment
* @return true if no errors found, false if we can't use this env
*/
static bool sanitycheck(void) {
/* One of our biggest problems is old and bogus libevents */
const char *ever = event_get_version();
if (ever != NULL) {
if (strncmp(ever, "1.", 2) == 0) {
/* Require at least 1.3 (that's still a couple of years old) */
if ((ever[2] == '1' || ever[2] == '2') && !isdigit(ever[3])) {
fprintf(stderr, "You are using libevent %s.\nPlease upgrade to"
" a more recent version (1.3 or newer)\n",
event_get_version());
return false;
}
}
}

return true;
}

int main (int argc, char **argv) { int main (int argc, char **argv) {
int c; int c;
bool lock_memory = false; bool lock_memory = false;
Expand All @@ -4271,6 +4294,10 @@ int main (int argc, char **argv) {
bool tcp_specified = false; bool tcp_specified = false;
bool udp_specified = false; bool udp_specified = false;


if (!sanitycheck()) {
return EX_OSERR;
}

/* handle SIGINT */ /* handle SIGINT */
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);


Expand Down
2 changes: 1 addition & 1 deletion t/binary.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3361; use Test::More tests => 3373;
use FindBin qw($Bin); use FindBin qw($Bin);
use lib "$Bin/lib"; use lib "$Bin/lib";
use MemcachedTest; use MemcachedTest;
Expand Down
3 changes: 2 additions & 1 deletion t/stats.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ my $sock = $server->sock;
## STAT uptime 13 ## STAT uptime 13
## STAT time 1259170891 ## STAT time 1259170891
## STAT version 1.4.3 ## STAT version 1.4.3
## STAT libevent 1.4.13-stable.
## STAT pointer_size 32 ## STAT pointer_size 32
## STAT rusage_user 0.001198 ## STAT rusage_user 0.001198
## STAT rusage_system 0.003523 ## STAT rusage_system 0.003523
Expand Down Expand Up @@ -57,7 +58,7 @@ my $sock = $server->sock;
my $stats = mem_stats($sock); my $stats = mem_stats($sock);


# Test number of keys # Test number of keys
is(scalar(keys(%$stats)), 38, "38 stats values"); is(scalar(keys(%$stats)), 39, "39 stats values");


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

0 comments on commit b942304

Please sign in to comment.