aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2012-10-15 11:37:14 -0700
committerAndrea Shepard <andrea@torproject.org>2012-10-15 12:22:20 -0700
commitac227cf587c17fb2bdd10de4b320ea4df3632cd8 (patch)
treef50ae4c556fbfe33f2ca1312a5cc5c21652f3a11
parent99057014bae3b7a19ae9cf50cad2063a3c085e14 (diff)
downloadtor-ac227cf587c17fb2bdd10de4b320ea4df3632cd8.tar
tor-ac227cf587c17fb2bdd10de4b320ea4df3632cd8.tar.gz
Close and free channel_tls_listener correctly in channel_tls_free_all()
-rw-r--r--src/or/channeltls.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 1a2956b75..62bb18bb8 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -216,14 +216,26 @@ channel_tls_start_listener(void)
void
channel_tls_free_all(void)
{
+ channel_listener_t *old_listener = NULL;
+
log_debug(LD_CHANNEL,
"Shutting down TLS channels...");
if (channel_tls_listener) {
- channel_listener_unregister(channel_tls_listener);
- channel_listener_mark_for_close(channel_tls_listener);
- channel_listener_free(channel_tls_listener);
- channel_tls_listener = NULL;
+ /*
+ * When we close it, channel_tls_listener will get nulled out, so save
+ * a pointer so we can free it.
+ */
+ old_listener = channel_tls_listener;
+ log_debug(LD_CHANNEL,
+ "Closing channel_tls_listener with ID " U64_FORMAT
+ " at %p.",
+ U64_PRINTF_ARG(old_listener->global_identifier),
+ old_listener);
+ channel_listener_unregister(old_listener);
+ channel_listener_mark_for_close(old_listener);
+ channel_listener_free(old_listener);
+ tor_assert(channel_tls_listener == NULL);
}
log_debug(LD_CHANNEL,