aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-08-18 15:08:49 -0400
committerNick Mathewson <nickm@torproject.org>2011-08-18 15:16:05 -0400
commitd3653063d30ee8174f6ec330124553c6717fbe9c (patch)
tree8b79ef5db5ab4b85cf5296f26836b21b7210db3e /src
parent52e36feda153e70cd08d624df73035b7e59a95ef (diff)
downloadtor-d3653063d30ee8174f6ec330124553c6717fbe9c.tar
tor-d3653063d30ee8174f6ec330124553c6717fbe9c.tar.gz
Automatically use filtering bufferevents with IOCP.
Diffstat (limited to 'src')
-rw-r--r--src/common/compat_libevent.c11
-rw-r--r--src/common/compat_libevent.h1
-rw-r--r--src/common/tortls.c2
3 files changed, 13 insertions, 1 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 8752de749..595742f96 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -164,6 +164,16 @@ struct event_base *the_event_base = NULL;
#endif
#endif
+#ifdef USE_BUFFEREVENTS
+static int using_iocp_bufferevents = 0;
+
+int
+tor_libevent_using_iocp_bufferevents(void)
+{
+ return using_iocp_bufferevents;
+}
+#endif
+
/** Initialize the Libevent library and set up the event base. */
void
tor_libevent_initialize(tor_libevent_cfg *torcfg)
@@ -187,6 +197,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
if (! torcfg->disable_iocp) {
evthread_use_windows_threads();
event_config_set_flag(cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
+ using_iocp_bufferevents = 1;
}
#endif
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index 8669fd4e0..bbe105bf4 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -73,6 +73,7 @@ const char *tor_libevent_get_version_str(void);
#ifdef USE_BUFFEREVENTS
#define TOR_LIBEVENT_TICKS_PER_SECOND 3
const struct timeval *tor_libevent_get_one_tick_timeout(void);
+int tor_libevent_using_iocp_bufferevents(void);
#endif
#endif
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 455603030..2aaa2c49b 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -1892,7 +1892,7 @@ tor_tls_init_bufferevent(tor_tls_t *tls, struct bufferevent *bufev_in,
const enum bufferevent_ssl_state state = receiving ?
BUFFEREVENT_SSL_ACCEPTING : BUFFEREVENT_SSL_CONNECTING;
- if (filter) {
+ if (filter || tor_libevent_using_iocp_bufferevents()) {
/* Grab an extra reference to the SSL, since BEV_OPT_CLOSE_ON_FREE
means that the SSL will get freed too.