diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-02-09 23:16:31 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-02-09 23:16:31 +0000 |
commit | 89d422914a0c3cbba5e3827248f97c536ce69de5 (patch) | |
tree | 8cc472ee158940dab21288408061b911cc7300a7 | |
parent | 0d5dedd732de1f5e3c2408d21b4b15c5adc30662 (diff) | |
download | tor-89d422914a0c3cbba5e3827248f97c536ce69de5.tar.gz tor-89d422914a0c3cbba5e3827248f97c536ce69de5.zip |
Patch from adam langley: always remove sockets from libevent before closing them. Should fix epoll-related bugs.
svn:r3606
-rw-r--r-- | src/or/connection.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index cf42edba81..dccbfc6771 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -163,10 +163,6 @@ _connection_free(connection_t *conn) { tor_free(conn->nickname); tor_free(conn->socks_request); - if (conn->s >= 0) { - log_fn(LOG_INFO,"closing fd %d.",conn->s); - tor_close_socket(conn->s); - } if (conn->read_event) { event_del(conn->read_event); tor_free(conn->read_event); @@ -175,6 +171,11 @@ _connection_free(connection_t *conn) { event_del(conn->write_event); tor_free(conn->write_event); } + if (conn->s >= 0) { + log_fn(LOG_INFO,"closing fd %d.",conn->s); + tor_close_socket(conn->s); + } + memset(conn, 0xAA, sizeof(connection_t)); /* poison memory */ tor_free(conn); } @@ -309,6 +310,16 @@ void connection_close_immediate(connection_t *conn) conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state, (int)conn->outbuf_flushlen); } + if (conn->read_event) { + event_del(conn->read_event); + tor_free(conn->read_event); + conn->read_event = NULL; + } + if (conn->write_event) { + event_del(conn->write_event); + tor_free(conn->write_event); + conn->write_event = NULL; + } tor_close_socket(conn->s); conn->s = -1; if (!connection_is_listener(conn)) { |