diff options
author | Trond Norbye <trond.norbye@gmail.com> | 2010-06-04 12:01:16 +0200 |
---|---|---|
committer | Trond Norbye <trond.norbye@gmail.com> | 2010-09-14 08:59:40 +0200 |
commit | b942304483cde8d0cdd2001f4f972379c9afefb4 (patch) | |
tree | b63380e8339e1716be545ced42f9cbf4ecebe880 | |
parent | 39f6eeb3f50a25241da389b18f89a54daa659d50 (diff) | |
download | memcached-b942304483cde8d0cdd2001f4f972379c9afefb4.tar.gz |
Refuse to start if we detect libevent 1.[12]
-rw-r--r-- | memcached.c | 27 | ||||
-rwxr-xr-x | t/binary.t | 2 | ||||
-rwxr-xr-x | t/stats.t | 3 |
3 files changed, 30 insertions, 2 deletions
diff --git a/memcached.c b/memcached.c index 750c8b3..6f31ea4 100644 --- a/memcached.c +++ b/memcached.c @@ -2374,6 +2374,7 @@ static void server_stats(ADD_STAT add_stats, conn *c) { APPEND_STAT("uptime", "%u", now); APPEND_STAT("time", "%ld", now + (long)process_started); APPEND_STAT("version", "%s", VERSION); + APPEND_STAT("libevent", "%s", event_get_version()); APPEND_STAT("pointer_size", "%d", (int)(8 * sizeof(void *))); #ifndef WIN32 @@ -4250,6 +4251,28 @@ static int enable_large_pages(void) { #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 c; bool lock_memory = false; @@ -4271,6 +4294,10 @@ int main (int argc, char **argv) { bool tcp_specified = false; bool udp_specified = false; + if (!sanitycheck()) { + return EX_OSERR; + } + /* handle SIGINT */ signal(SIGINT, sig_handler); @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 3361; +use Test::More tests => 3373; use FindBin qw($Bin); use lib "$Bin/lib"; use MemcachedTest; @@ -16,6 +16,7 @@ my $sock = $server->sock; ## STAT uptime 13 ## STAT time 1259170891 ## STAT version 1.4.3 +## STAT libevent 1.4.13-stable. ## STAT pointer_size 32 ## STAT rusage_user 0.001198 ## STAT rusage_system 0.003523 @@ -57,7 +58,7 @@ my $sock = $server->sock; my $stats = mem_stats($sock); # Test number of keys -is(scalar(keys(%$stats)), 38, "38 stats values"); +is(scalar(keys(%$stats)), 39, "39 stats values"); # Test initial state foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses |