Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refuse to start if we detect libevent 1.[12]

  • Loading branch information...
commit b942304483cde8d0cdd2001f4f972379c9afefb4 1 parent 39f6eeb
@trondn trondn authored
Showing with 30 additions and 2 deletions.
  1. +27 −0 memcached.c
  2. +1 −1  t/binary.t
  3. +2 −1  t/stats.t
View
27 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);
View
2  t/binary.t
@@ -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;
View
3  t/stats.t
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.