diff options
Diffstat (limited to 'memcached.c')
-rw-r--r-- | memcached.c | 27 |
1 files changed, 27 insertions, 0 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); |