Przeglądaj źródła

Merge branch 'bug4457_022' into maint-0.2.2

Nick Mathewson 12 lat temu
rodzic
commit
5a02406ae0
2 zmienionych plików z 27 dodań i 1 usunięć
  1. 9 0
      changes/bug4457
  2. 18 1
      src/common/compat_libevent.c

+ 9 - 0
changes/bug4457

@@ -0,0 +1,9 @@
+  o Minor bugfixes:
+    - Initialize Libevent with the EVENT_BASE_FLAG_NOLOCK flag enabled, so
+      that it doesn't attempt to allocate a socketpair. This could cause
+      some problems on windows systems with overzealous firewalls. Fix for
+      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.
+

+ 18 - 1
src/common/compat_libevent.c

@@ -177,11 +177,28 @@ tor_libevent_initialize(void)
 #endif
 
 #ifdef HAVE_EVENT2_EVENT_H
-  the_event_base = event_base_new();
+  {
+    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.
+     */
+    event_config_set_flag(cfg, EVENT_BASE_FLAG_NOLOCK);
+
+    the_event_base = event_base_new_with_config(cfg);
+
+    event_config_free(cfg);
+  }
 #else
   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. */