summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-08-11 17:45:01 -0400
committerNick Mathewson <nickm@torproject.org>2010-09-27 12:31:13 -0400
commit84bb5d573c7b067821debc62538dfb99aa44fd53 (patch)
tree75079b0e8b9470460ffc39cb0646fac368d93ceb /src/or
parent44375d4eb8d9336c074d7e224cb118f1ad7e6f54 (diff)
downloadtor-84bb5d573c7b067821debc62538dfb99aa44fd53.tar.gz
tor-84bb5d573c7b067821debc62538dfb99aa44fd53.zip
Fix crash/warning bug when we get an unexpected close.
This was possible if we have already decided to close a bufferevent connection, but the other side decides to close it first.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 8b9d47d5d1..24fc9f206b 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -700,10 +700,9 @@ connection_close_immediate(connection_t *conn)
conn->s = -1;
if (conn->linked)
conn->linked_conn_is_closed = 1;
- if (!connection_is_listener(conn)) {
+ if (conn->outbuf)
buf_clear(conn->outbuf);
- conn->outbuf_flushlen = 0;
- }
+ conn->outbuf_flushlen = 0;
}
/** Mark <b>conn</b> to be closed next time we loop through
@@ -2721,12 +2720,14 @@ connection_handle_event_cb(struct bufferevent *bufev, short event, void *arg)
tor_socket_strerror(socket_error));
} else if (CONN_IS_EDGE(conn)) {
edge_connection_t *edge_conn = TO_EDGE_CONN(conn);
- connection_edge_end_errno(edge_conn);
+ if (!edge_conn->edge_has_sent_end)
+ connection_edge_end_errno(edge_conn);
if (edge_conn->socks_request) /* broken, don't send a socks reply back */
edge_conn->socks_request->has_finished = 1;
}
connection_close_immediate(conn); /* Connection is dead. */
- connection_mark_for_close(conn);
+ if (!conn->marked_for_close)
+ connection_mark_for_close(conn);
}
}