]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
set SO_REUSEADDR before we bind, not after
authorRoger Dingledine <arma@torproject.org>
Mon, 23 Jan 2012 20:54:02 +0000 (15:54 -0500)
committerRoger Dingledine <arma@torproject.org>
Mon, 23 Jan 2012 20:54:02 +0000 (15:54 -0500)
resolves bug 4950 (fixes a bug on commit aba7bb705a6 from #2850)

changes/bug4950 [new file with mode: 0644]
src/or/connection.c

diff --git a/changes/bug4950 b/changes/bug4950
new file mode 100644 (file)
index 0000000..d91ec46
--- /dev/null
@@ -0,0 +1,6 @@
+  o Major bugfixes:
+    - Set the SO_REUSEADDR socket option before we call bind() on outgoing
+      connections. This change should allow busy exit relays to stop
+      running out of available sockets as quickly. Fixes bug 4950;
+      bugfix on 0.2.2.26-beta.
+
index 462022dffde0c98029397d78fd2c976c622eb475..c51e7fbeffe4f50543355246b92aa851e349de61 100644 (file)
@@ -1338,6 +1338,8 @@ connection_connect(connection_t *conn, const char *address,
     return -1;
   }
 
+  make_socket_reuseable(s);
+
   if (options->OutboundBindAddress && !tor_addr_is_loopback(addr)) {
     struct sockaddr_in ext_addr;
 
@@ -1372,8 +1374,6 @@ connection_connect(connection_t *conn, const char *address,
   log_debug(LD_NET, "Connecting to %s:%u.",
             escaped_safe_str_client(address), port);
 
-  make_socket_reuseable(s);
-
   if (connect(s, dest_addr, (socklen_t)dest_addr_len) < 0) {
     int e = tor_socket_errno(s);
     if (!ERRNO_IS_CONN_EINPROGRESS(e)) {