From 707c1e2e263fd34f70a5f780e77820d667ba2931 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Thu, 6 Feb 2014 14:47:34 -0800 Subject: NULL out conns on tlschans when freeing in case channel_run_cleanup() is late; fixes bug 9602 --- src/or/connection.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/or/connection.c') diff --git a/src/or/connection.c b/src/or/connection.c index 062c97114a..4f74a1d04b 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -514,6 +514,22 @@ connection_free_(connection_t *conn) or_handshake_state_free(or_conn->handshake_state); or_conn->handshake_state = NULL; tor_free(or_conn->nickname); + if (or_conn->chan) { + /* Owww, this shouldn't happen, but... */ + log_info(LD_CHANNEL, + "Freeing orconn at %p, saw channel %p with ID " + U64_FORMAT " left un-NULLed", + or_conn, TLS_CHAN_TO_BASE(or_conn->chan), + U64_PRINTF_ARG( + TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier)); + if (!(TLS_CHAN_TO_BASE(or_conn->chan)->state == CHANNEL_STATE_CLOSED || + TLS_CHAN_TO_BASE(or_conn->chan)->state == CHANNEL_STATE_ERROR)) { + channel_close_for_error(TLS_CHAN_TO_BASE(or_conn->chan)); + } + + or_conn->chan->conn = NULL; + or_conn->chan = NULL; + } } if (conn->type == CONN_TYPE_AP) { entry_connection_t *entry_conn = TO_ENTRY_CONN(conn); -- cgit v1.2.3-54-g00ecf