Browse Source

Merge remote-tracking branch 'public/bug4457_022' into bug4457_master

Conflicts:
	src/common/compat_libevent.c

Resolving conflict by not taking 7363eae13cb8 ("Use the
EVENT_BASE_FLAG_NOLOCK flag to prevent socketpair() invocation"): in
Tor 0.2.3.x, we _do_ sometimes use notifiable event bases.
Nick Mathewson 14 years ago
parent
commit
cf8117136c
2 changed files with 15 additions and 0 deletions
  1. 9 0
      changes/bug4457
  2. 6 0
      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.
+

+ 6 - 0
src/common/compat_libevent.c

@@ -196,6 +196,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
 #ifdef HAVE_EVENT2_EVENT_H
 #ifdef HAVE_EVENT2_EVENT_H
   {
   {
     struct event_config *cfg = event_config_new();
     struct event_config *cfg = event_config_new();
+    tor_assert(cfg);
 
 
 #if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
 #if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
     if (! torcfg->disable_iocp) {
     if (! torcfg->disable_iocp) {
@@ -224,6 +225,11 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
   the_event_base = event_init();
   the_event_base = event_init();
 #endif
 #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)
 #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
   /* Making this a NOTICE for now so we can link bugs to a libevent versions
    * or methods better. */
    * or methods better. */