@@ -2374,6 +2374,7 @@ static void server_stats(ADD_STAT add_stats, conn *c) {
2374
2374
APPEND_STAT ("uptime" , "%u" , now );
2375
2375
APPEND_STAT ("time" , "%ld" , now + (long )process_started );
2376
2376
APPEND_STAT ("version" , "%s" , VERSION );
2377
+ APPEND_STAT ("libevent" , "%s" , event_get_version ());
2377
2378
APPEND_STAT ("pointer_size" , "%d" , (int )(8 * sizeof (void * )));
2378
2379
2379
2380
#ifndef WIN32
@@ -4250,6 +4251,28 @@ static int enable_large_pages(void) {
4250
4251
#endif
4251
4252
}
4252
4253
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
+
4253
4276
int main (int argc , char * * argv ) {
4254
4277
int c ;
4255
4278
bool lock_memory = false;
@@ -4271,6 +4294,10 @@ int main (int argc, char **argv) {
4271
4294
bool tcp_specified = false;
4272
4295
bool udp_specified = false;
4273
4296
4297
+ if (!sanitycheck ()) {
4298
+ return EX_OSERR ;
4299
+ }
4300
+
4274
4301
/* handle SIGINT */
4275
4302
signal (SIGINT , sig_handler );
4276
4303
0 commit comments