summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-02-23 13:03:07 -0500
committerNick Mathewson <nickm@torproject.org>2015-02-23 13:03:07 -0500
commit098cbcbb9ec13861b8c95f6ba5b1581177a1971a (patch)
tree7be28758d3d4bc6ac9720548aece1c039353d0e8 /src
parent21ac0cd2afb2275bfe89237c3aeb545fb7de537e (diff)
parentf1fa85ea7325269fdb9f2d82257104d51f58b6a6 (diff)
downloadtor-098cbcbb9ec13861b8c95f6ba5b1581177a1971a.tar.gz
tor-098cbcbb9ec13861b8c95f6ba5b1581177a1971a.zip
Merge branch 'bug14989'
Diffstat (limited to 'src')
-rw-r--r--src/or/connection.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 79ae178a56..7db0238b3d 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1612,7 +1612,6 @@ connection_connect_sockaddr(connection_t *conn,
tor_socket_t s;
int inprogress = 0;
const or_options_t *options = get_options();
- int protocol_family;
tor_assert(conn);
tor_assert(sa);
@@ -1624,8 +1623,6 @@ connection_connect_sockaddr(connection_t *conn,
return -1;
}
- protocol_family = sa->sa_family;
-
if (get_options()->DisableNetwork) {
/* We should never even try to connect anyplace if DisableNetwork is set.
* Warn if we do, and refuse to make the connection. */
@@ -1637,7 +1634,11 @@ connection_connect_sockaddr(connection_t *conn,
return -1;
}
- s = tor_open_socket_nonblocking(protocol_family, SOCK_STREAM, 0);
+ const int protocol_family = sa->sa_family;
+ const int proto = (sa->sa_family == AF_INET6 ||
+ sa->sa_family == AF_INET) ? IPPROTO_TCP : 0;
+
+ s = tor_open_socket_nonblocking(protocol_family, SOCK_STREAM, proto);
if (! SOCKET_OK(s)) {
*socket_error = tor_socket_errno(-1);
log_warn(LD_NET,"Error creating network socket: %s",