[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.2] Detect failure from event_init() or event_base_new_with_config()



commit 0f6c02161793fa1022fe721ed9c1aac3538294b3
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Nov 14 17:53:45 2011 -0500

    Detect failure from event_init() or event_base_new_with_config()
---
 changes/bug4457              |    1 +
 src/common/compat_libevent.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/changes/bug4457 b/changes/bug4457
index d3d9eb3..fe7c95f 100644
--- a/changes/bug4457
+++ b/changes/bug4457
@@ -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.
 
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 3e35e09..ddb2da6 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -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. */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits