[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r7004: Experimentally re-enable kqueue on OSX when using libevent 1 (tor/trunk/src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r7004: Experimentally re-enable kqueue on OSX when using libevent 1 (tor/trunk/src/or)
- From: nickm@xxxxxxxx
- Date: Thu, 10 Aug 2006 04:00:14 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Thu, 10 Aug 2006 04:00:30 -0400
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2006-08-10 04:00:13 -0400 (Thu, 10 Aug 2006)
New Revision: 7004
Modified:
tor/trunk/src/or/config.c
Log:
Experimentally re-enable kqueue on OSX when using libevent 1.1b or later. Log when we are doing this, so we can diagnose it when it fails.
Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c 2006-08-10 07:39:47 UTC (rev 7003)
+++ tor/trunk/src/or/config.c 2006-08-10 08:00:13 UTC (rev 7004)
@@ -392,8 +392,12 @@
static void print_cvs_version(void);
static void init_libevent(void);
static int opt_streq(const char *s1, const char *s2);
+typedef enum {
+ LE_OLD=0, LE_10C, LE_10D, LE_10E, LE_11, LE_11A, LE_11B, LE_OTHER
+} le_version_t;
+static le_version_t decode_libevent_version(void);
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
-static void check_libevent_version(const char *m, const char *v, int server);
+static void check_libevent_version(const char *m, int server);
#endif
/*static*/ or_options_t *options_new(void);
@@ -3546,8 +3550,20 @@
*/
suppress_libevent_log_msg("Function not implemented");
#ifdef __APPLE__
- setenv("EVENT_NOKQUEUE","1",1);
+ if (decode_libevent_version() < LE_11B) {
+ setenv("EVENT_NOKQUEUE","1",1);
+ } else if (!getenv("EVENT_NOKQUEUE")) {
+ const char *ver = NULL;
+#ifdef HAVE_EVENT_GET_VERSION
+ ver = event_get_version();
#endif
+ tor_assert(ver); /* If we're 1.1b or later, we'd better have get_version()*/
+ log(LOG_NOTICE, LD_GENERAL, "Enabling experimental OS X kqueue support "
+ "with libevent %s. If this turns out to not work, "
+ "set the environment variable EVENT_NOKQUEUE, and tell the Tor "
+ "developers.", ver);
+ }
+#endif
event_init();
suppress_libevent_log_msg(NULL);
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
@@ -3556,8 +3572,7 @@
log(LOG_NOTICE, LD_GENERAL,
"Initialized libevent version %s using method %s. Good.",
event_get_version(), event_get_method());
- check_libevent_version(event_get_method(), event_get_version(),
- get_options()->ORPort != 0);
+ check_libevent_version(event_get_method(), get_options()->ORPort != 0);
#else
log(LOG_NOTICE, LD_GENERAL,
"Initialized old libevent (version 1.0b or earlier).");
@@ -3568,10 +3583,6 @@
}
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
-typedef enum {
- LE_10C=0, LE_10D, LE_10E, LE_11, LE_11A, LE_11B, LE_OTHER
-} le_version_t;
-
static const struct {
const char *name; le_version_t version;
} le_version_table[] = {
@@ -3585,25 +3596,32 @@
{ NULL, 0 }
};
+static le_version_t
+decode_libevent_version(void)
+{
+ const char *v = event_get_version();
+ int i;
+ for (i=0; le_version_table[i].name; ++i) {
+ if (!strcmp(le_version_table[i].name, v)) {
+ return le_version_table[i].version;
+ }
+ }
+ return LE_OTHER;
+}
+
/**
* Compare the given libevent method and version to a list of versions
* which are known not to work. Warn the user as appropriate.
*
*/
static void
-check_libevent_version(const char *m, const char *v, int server)
+check_libevent_version(const char *m, int server)
{
int buggy = 0, iffy = 0, slow = 0;
- int i;
- le_version_t version = LE_OTHER;
- tor_assert(m && v);
+ le_version_t version;
+ const char *v = event_get_version();
- for (i=0; le_version_table[i].name; ++i) {
- if (!strcmp(le_version_table[i].name, v)) {
- version = le_version_table[i].version;
- break;
- }
- }
+ version = decode_libevent_version();
if (!strcmp(m, "kqueue")) {
if (version < LE_11B)
@@ -3640,6 +3658,12 @@
}
}
+#else
+static le_version_t
+decode_libevent_version(void)
+{
+ return LE_OLD;
+}
#endif
/** Return the persistent state struct for this Tor. */