diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-03 15:41:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-09-03 15:41:50 -0400 |
commit | 9b2a0f5c755b0dc4a93c6a77e3f6bdb59a3ba96c (patch) | |
tree | 30c37f1be9e57e6f1bafcbdc21970ba1bbfeeea5 /src/common/compat.c | |
parent | 5c9008e0b077e79297a5245573675d95a1f266cc (diff) | |
parent | a8e76de4d997690917432d0d60383a1333f80baa (diff) | |
download | tor-9b2a0f5c755b0dc4a93c6a77e3f6bdb59a3ba96c.tar.gz tor-9b2a0f5c755b0dc4a93c6a77e3f6bdb59a3ba96c.zip |
Merge remote-tracking branch 'origin/maint-0.2.4'
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 3768933edf..d6ea41878a 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1313,9 +1313,9 @@ tor_ersatz_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) * for now, and really, when localhost is down sometimes, we * have other problems too. */ - tor_socket_t listener = -1; - tor_socket_t connector = -1; - tor_socket_t acceptor = -1; + tor_socket_t listener = TOR_INVALID_SOCKET; + tor_socket_t connector = TOR_INVALID_SOCKET; + tor_socket_t acceptor = TOR_INVALID_SOCKET; struct sockaddr_in listen_addr; struct sockaddr_in connect_addr; socklen_t size; @@ -1369,7 +1369,6 @@ tor_ersatz_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) goto tidy_up_and_fail; if (size != sizeof(listen_addr)) goto abort_tidy_up_and_fail; - tor_close_socket(listener); /* Now check we are talking to ourself by matching port and host on the two sockets. */ if (getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -1) @@ -1380,6 +1379,7 @@ tor_ersatz_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) || listen_addr.sin_port != connect_addr.sin_port) { goto abort_tidy_up_and_fail; } + tor_close_socket(listener); fd[0] = connector; fd[1] = acceptor; @@ -1394,11 +1394,11 @@ tor_ersatz_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) tidy_up_and_fail: if (saved_errno < 0) saved_errno = errno; - if (listener != -1) + if (SOCKET_OK(listener)) tor_close_socket(listener); - if (connector != -1) + if (SOCKET_OK(connector)) tor_close_socket(connector); - if (acceptor != -1) + if (SOCKET_OK(acceptor)) tor_close_socket(acceptor); return -saved_errno; } |