diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-02-19 23:46:08 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-02-19 23:46:08 +0000 |
commit | 0399538b90ad38bd0d5d8f4c37467666cd36c2e5 (patch) | |
tree | 106f4fb72b26a5764efa187b2e7ce4de727dd098 /src | |
parent | 707da4f73f86edf8df6baf5b4c0759e49f817694 (diff) | |
download | tor-0399538b90ad38bd0d5d8f4c37467666cd36c2e5.tar.gz tor-0399538b90ad38bd0d5d8f4c37467666cd36c2e5.zip |
r18233@catbus: nickm | 2008-02-19 18:46:07 -0500
Count sockets returned from socketpair() too. This is probably not the socket counting bug.
svn:r13600
Diffstat (limited to 'src')
-rw-r--r-- | src/common/compat.c | 10 | ||||
-rw-r--r-- | src/or/connection.c | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index aa84b7a965..d443fc6aa6 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -637,6 +637,16 @@ tor_socketpair(int family, int type, int protocol, int fd[2]) #if defined(HAVE_SOCKETPAIR) && !defined(MS_WINDOWS) int r; r = socketpair(family, type, protocol, fd); + if (r == 0) { + if (fd[0] >= 0) { + ++n_sockets_open; + mark_socket_open(fd[0]); + } + if (fd[1] >= 0) { + ++n_sockets_open; + mark_socket_open(fd[1]); + } + } return r < 0 ? -errno : r; #elif defined(USE_BSOCKETS) return bsocketpair(family, type, protocol, fd); diff --git a/src/or/connection.c b/src/or/connection.c index db50e87402..f7ecdea0fc 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -366,6 +366,7 @@ _connection_free(connection_t *conn) if (conn->s >= 0) { log_debug(LD_NET,"closing fd %d.",conn->s); tor_close_socket(conn->s); + conn->s = -1; } if (conn->type == CONN_TYPE_OR && |