aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat_libevent.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-09-28 14:01:45 -0400
committerNick Mathewson <nickm@torproject.org>2010-09-28 14:01:45 -0400
commitc612ddee17c2f6e70fde9f0bdd7116516f384ae8 (patch)
treec2113145b817030aa8e0b1fd1d97ec65338a39a9 /src/common/compat_libevent.c
parentd6e255edbd11f159c33ff77ceb638c0304dd9873 (diff)
downloadtor-c612ddee17c2f6e70fde9f0bdd7116516f384ae8.tar
tor-c612ddee17c2f6e70fde9f0bdd7116516f384ae8.tar.gz
Add a new option to enable/disable IOCP support
Diffstat (limited to 'src/common/compat_libevent.c')
-rw-r--r--src/common/compat_libevent.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index bbab06e8d..6afd3c1d2 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -159,7 +159,7 @@ struct event_base *the_event_base = NULL;
/** Initialize the Libevent library and set up the event base. */
void
-tor_libevent_initialize(void)
+tor_libevent_initialize(tor_libevent_cfg *torcfg)
{
tor_assert(the_event_base == NULL);
@@ -171,7 +171,21 @@ tor_libevent_initialize(void)
#endif
#ifdef HAVE_EVENT2_EVENT_H
- the_event_base = event_base_new();
+ {
+ struct event_config *cfg = event_config_new();
+
+#if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
+ if (! torcfg->disable_iocp)
+ event_config_set_flag(cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
+#endif
+
+#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= V(2,0,7)
+ if (torcfg->num_cpus > 0)
+ event_config_set_num_cpus_hint(cfg, torcfg->num_cpus);
+#endif
+
+ the_event_base = event_base_new_with_config(cfg);
+ }
#else
the_event_base = event_init();
#endif