diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-11-24 22:59:37 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-11-24 22:59:37 -0500 |
commit | f634228a073965195c4088b66c1d5c4799c6eed2 (patch) | |
tree | 3113bac14b861247cc900851104ef8c246292477 /src | |
parent | 11221d0f17bf3ea6039249ad8b06b3a1afd6291d (diff) | |
parent | 6e6a6612966d7ea9ad3d89bb5073ef400539b2a7 (diff) | |
download | tor-f634228a073965195c4088b66c1d5c4799c6eed2.tar.gz tor-f634228a073965195c4088b66c1d5c4799c6eed2.zip |
Merge remote-tracking branch 'public/feature4516'
Diffstat (limited to 'src')
-rw-r--r-- | src/or/config.c | 1 | ||||
-rw-r--r-- | src/or/main.c | 28 | ||||
-rw-r--r-- | src/or/or.h | 5 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c index 06d7d5c022..ef9e4ecee4 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -405,6 +405,7 @@ static config_var_t _option_vars[] = { V(UseEntryGuards, BOOL, "1"), V(UseMicrodescriptors, AUTOBOOL, "auto"), V(User, STRING, NULL), + V(UserspaceIOCPBuffers, BOOL, "0"), VAR("V1AuthoritativeDirectory",BOOL, V1AuthoritativeDir, "0"), VAR("V2AuthoritativeDirectory",BOOL, V2AuthoritativeDir, "0"), VAR("V3AuthoritativeDirectory",BOOL, V3AuthoritativeDir, "0"), diff --git a/src/or/main.c b/src/or/main.c index 7008d388a1..10b80a4dd9 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -196,6 +196,26 @@ free_old_inbuf(connection_t *conn) } #endif +#ifdef MS_WINDOWS +/** Remove the kernel-space send and receive buffers for <b>s</b>. For use + * with IOCP only. */ +static int +set_buffer_lengths_to_zero(tor_socket_t s) +{ + int zero = 0; + int r = 0; + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, (void*)&zero, sizeof(zero))) { + log_warn(LD_NET, "Unable to clear SO_SNDBUF"); + r = -1; + } + if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void*)&zero, sizeof(zero))) { + log_warn(LD_NET, "Unable to clear SO_RCVBUF"); + r = -1; + } + return r; +} +#endif + /** Add <b>conn</b> to the array of connections that we can poll on. The * connection's socket must be set; the connection starts out * non-reading and non-writing. @@ -216,6 +236,14 @@ connection_add_impl(connection_t *conn, int is_connecting) #ifdef USE_BUFFEREVENTS if (connection_type_uses_bufferevent(conn)) { if (SOCKET_OK(conn->s) && !conn->linked) { + +#ifdef MS_WINDOWS + if (tor_libevent_using_iocp_bufferevents() && + get_options()->UserspaceIOCPBuffers) { + set_buffer_lengths_to_zero(conn->s); + } +#endif + conn->bufev = bufferevent_socket_new( tor_libevent_get_base(), conn->s, diff --git a/src/or/or.h b/src/or/or.h index 67ba62bdd6..f186eac7bd 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3432,6 +3432,11 @@ typedef struct { * never use it. If -1, we do what the consensus says. */ int OptimisticData; + /** If 1, and we are using IOCP, we set the kernel socket SNDBUF and RCVBUF + * to 0 to try to save kernel memory and avoid the dread "Out of buffers" + * issue. */ + int UserspaceIOCPBuffers; + } or_options_t; /** Persistent state for an onion router, as saved to disk. */ |