summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2014-02-06 14:47:34 -0800
committerAndrea Shepard <andrea@torproject.org>2014-02-06 14:47:34 -0800
commit707c1e2e263fd34f70a5f780e77820d667ba2931 (patch)
tree8b6365594d3dd5171c6b435c37c13b8ffa485428 /src/or/connection.c
parentb4e8d8dc0e6f942346895a5cff123db3aa1f94d5 (diff)
downloadtor-707c1e2e263fd34f70a5f780e77820d667ba2931.tar.gz
tor-707c1e2e263fd34f70a5f780e77820d667ba2931.zip
NULL out conns on tlschans when freeing in case channel_run_cleanup() is late; fixes bug 9602
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c16
1 files changed, 16 insertions, 0 deletions
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);