]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Detect failure from event_init() or event_base_new_with_config()
authorNick Mathewson <nickm@torproject.org>
Mon, 14 Nov 2011 22:53:45 +0000 (17:53 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 14 Nov 2011 22:53:45 +0000 (17:53 -0500)
changes/bug4457
src/common/compat_libevent.c

index d3d9eb3b40b1436dc00f2748dda8abe19c9092fa..fe7c95ff8070a8238f4c506fda434357b8b2284e 100644 (file)
@@ -5,4 +5,5 @@
       bug 4457; workaround for Libevent versions 2.0.1-alpha through
       2.0.15-stable.
 
+    - Detect failure to initialize Libevent. Better detection for bug 4457.
 
index 3e35e093e47fbaaf8fbd971680d04b4bb55e1789..ddb2da68aa40fc6c38fc904cb1869a84bace56ce 100644 (file)
@@ -179,6 +179,7 @@ tor_libevent_initialize(void)
 #ifdef HAVE_EVENT2_EVENT_H
   {
     struct event_config *cfg = event_config_new();
+    tor_assert(cfg);
 
     /* In 0.2.2, we don't use locking at all.  Telling Libevent not to try to
      * turn it on can avoid a needless socketpair() attempt.
@@ -193,6 +194,11 @@ tor_libevent_initialize(void)
   the_event_base = event_init();
 #endif
 
+  if (!the_event_base) {
+    log_err(LD_GENERAL, "Unable to initialize Libevent: cannot continue.");
+    exit(1);
+  }
+
 #if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
   /* Making this a NOTICE for now so we can link bugs to a libevent versions
    * or methods better. */