Browse Source

r12919@catbus: nickm | 2007-05-24 13:04:56 -0400
backport candidate: Warn when using a version of libevent before 1.3b to run a server on osx or bsd: these versions of libevent interact badly with userspace threads.


svn:r10307

Nick Mathewson 18 years ago
parent
commit
212a3c3478
2 changed files with 26 additions and 3 deletions
  1. 2 0
      ChangeLog
  2. 24 3
      src/or/config.c

+ 2 - 0
ChangeLog

@@ -117,6 +117,8 @@ Changes in version 0.2.0.1-alpha - 2007-??-??
 
 
   o Minor features (other):
   o Minor features (other):
     - More unit tests.
     - More unit tests.
+    - Warn when using a version of libevent before 1.3b to run a server on
+      OSX or BSD: these versions interact badly with userspace threads.
 
 
   o Removed features:
   o Removed features:
     - Removed support for the old binary "version 0" controller protocol.
     - Removed support for the old binary "version 0" controller protocol.

+ 24 - 3
src/or/config.c

@@ -598,7 +598,7 @@ typedef enum {
   /* Note: we compare these, so it's important that "old" precede everything,
   /* Note: we compare these, so it's important that "old" precede everything,
    * and that "other" come last. */
    * and that "other" come last. */
   LE_OLD=0, LE_10C, LE_10D, LE_10E, LE_11, LE_11A, LE_11B, LE_12, LE_12A,
   LE_OLD=0, LE_10C, LE_10D, LE_10E, LE_11, LE_11A, LE_11B, LE_12, LE_12A,
-  LE_13, LE_13A,
+  LE_13, LE_13A, LE_13B,
   LE_OTHER
   LE_OTHER
 } le_version_t;
 } le_version_t;
 static le_version_t decode_libevent_version(void);
 static le_version_t decode_libevent_version(void);
@@ -4034,6 +4034,7 @@ static const struct {
   { "1.2a", LE_12A },
   { "1.2a", LE_12A },
   { "1.3",  LE_13 },
   { "1.3",  LE_13 },
   { "1.3a", LE_13A },
   { "1.3a", LE_13A },
+  { "1.3b", LE_13B },
   { NULL, LE_OTHER }
   { NULL, LE_OTHER }
 };
 };
 
 
@@ -4060,10 +4061,11 @@ decode_libevent_version(void)
 static void
 static void
 check_libevent_version(const char *m, int server)
 check_libevent_version(const char *m, int server)
 {
 {
-  int buggy = 0, iffy = 0, slow = 0;
+  int buggy = 0, iffy = 0, slow = 0, thread_unsafe = 0;
   le_version_t version;
   le_version_t version;
   const char *v = event_get_version();
   const char *v = event_get_version();
   const char *badness = NULL;
   const char *badness = NULL;
+  const char *sad_os = "";
 
 
   version = decode_libevent_version();
   version = decode_libevent_version();
 
 
@@ -4096,7 +4098,26 @@ check_libevent_version(const char *m, int server)
       buggy = 1;
       buggy = 1;
   }
   }
 
 
-  if (buggy) {
+  /* Libevent versions before 1.3b do very badly on operating systems with
+   * user-space threading implementations. */
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
+  if (server && version < LE_13B) {
+    thread_unsafe = 1;
+    sad_os = "BSD variants"
+  }
+#elif defined(__APPLE__) || defined(__darwin__)
+  if (server && version < LE_13B) {
+    thread_unsafe = 1;
+    sad_os = "Mac OS X";
+  }
+#endif
+
+  if (thread_unsafe) {
+    log(LOG_WARN, LD_GENERAL,
+        "Libevent version %s often crashes when running a Tor server with %s. "
+        "Please use the latest version of libevent (1.3b or later)",v,sad_os);
+    badness = "BROKEN";
+  } else if (buggy) {
     log(LOG_WARN, LD_GENERAL,
     log(LOG_WARN, LD_GENERAL,
         "There are known bugs in using %s with libevent %s. "
         "There are known bugs in using %s with libevent %s. "
         "Please use the latest version of libevent.", m, v);
         "Please use the latest version of libevent.", m, v);