mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
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.
svn:r7004
This commit is contained in:
parent
f2a0df4d02
commit
35f0881802
@ -392,8 +392,12 @@ static int config_parse_interval(const char *s, int *ok);
|
|||||||
static void print_cvs_version(void);
|
static void print_cvs_version(void);
|
||||||
static void init_libevent(void);
|
static void init_libevent(void);
|
||||||
static int opt_streq(const char *s1, const char *s2);
|
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)
|
#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
|
#endif
|
||||||
|
|
||||||
/*static*/ or_options_t *options_new(void);
|
/*static*/ or_options_t *options_new(void);
|
||||||
@ -3546,7 +3550,19 @@ init_libevent(void)
|
|||||||
*/
|
*/
|
||||||
suppress_libevent_log_msg("Function not implemented");
|
suppress_libevent_log_msg("Function not implemented");
|
||||||
#ifdef __APPLE__
|
#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
|
#endif
|
||||||
event_init();
|
event_init();
|
||||||
suppress_libevent_log_msg(NULL);
|
suppress_libevent_log_msg(NULL);
|
||||||
@ -3556,8 +3572,7 @@ init_libevent(void)
|
|||||||
log(LOG_NOTICE, LD_GENERAL,
|
log(LOG_NOTICE, LD_GENERAL,
|
||||||
"Initialized libevent version %s using method %s. Good.",
|
"Initialized libevent version %s using method %s. Good.",
|
||||||
event_get_version(), event_get_method());
|
event_get_version(), event_get_method());
|
||||||
check_libevent_version(event_get_method(), event_get_version(),
|
check_libevent_version(event_get_method(), get_options()->ORPort != 0);
|
||||||
get_options()->ORPort != 0);
|
|
||||||
#else
|
#else
|
||||||
log(LOG_NOTICE, LD_GENERAL,
|
log(LOG_NOTICE, LD_GENERAL,
|
||||||
"Initialized old libevent (version 1.0b or earlier).");
|
"Initialized old libevent (version 1.0b or earlier).");
|
||||||
@ -3568,10 +3583,6 @@ init_libevent(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
|
#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 {
|
static const struct {
|
||||||
const char *name; le_version_t version;
|
const char *name; le_version_t version;
|
||||||
} le_version_table[] = {
|
} le_version_table[] = {
|
||||||
@ -3585,25 +3596,32 @@ static const struct {
|
|||||||
{ NULL, 0 }
|
{ 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
|
* Compare the given libevent method and version to a list of versions
|
||||||
* which are known not to work. Warn the user as appropriate.
|
* which are known not to work. Warn the user as appropriate.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void
|
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 buggy = 0, iffy = 0, slow = 0;
|
||||||
int i;
|
le_version_t version;
|
||||||
le_version_t version = LE_OTHER;
|
const char *v = event_get_version();
|
||||||
tor_assert(m && v);
|
|
||||||
|
|
||||||
for (i=0; le_version_table[i].name; ++i) {
|
version = decode_libevent_version();
|
||||||
if (!strcmp(le_version_table[i].name, v)) {
|
|
||||||
version = le_version_table[i].version;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(m, "kqueue")) {
|
if (!strcmp(m, "kqueue")) {
|
||||||
if (version < LE_11B)
|
if (version < LE_11B)
|
||||||
@ -3640,6 +3658,12 @@ check_libevent_version(const char *m, const char *v, int server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static le_version_t
|
||||||
|
decode_libevent_version(void)
|
||||||
|
{
|
||||||
|
return LE_OLD;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Return the persistent state struct for this Tor. */
|
/** Return the persistent state struct for this Tor. */
|
||||||
|
Loading…
Reference in New Issue
Block a user