Commit 89d42291 authored by Nick Mathewson's avatar Nick Mathewson 🌉
Browse files

Patch from adam langley: always remove sockets from libevent before closing...

Patch from adam langley: always remove sockets from libevent before closing them.  Should fix epoll-related bugs.


svn:r3606
parent 0d5dedd7
......@@ -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)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment