From 99057014bae3b7a19ae9cf50cad2063a3c085e14 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Mon, 15 Oct 2012 07:56:35 -0700 Subject: Add debug logging to channel_listener_free()/channel_listener_force_free() --- src/or/channel.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/or/channel.c b/src/or/channel.c index 2642431267..1a7a988fac 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -848,6 +848,11 @@ channel_listener_free(channel_listener_t *chan_l) { if (!chan_l) return; + log_debug(LD_CHANNEL, + "Freeing channel_listener_t " U64_FORMAT " at %p", + U64_PRINTF_ARG(chan_l->global_identifier), + chan_l); + /* It must be closed or errored */ tor_assert(chan_l->state == CHANNEL_LISTENER_STATE_CLOSED || chan_l->state == CHANNEL_LISTENER_STATE_ERROR); @@ -935,6 +940,11 @@ channel_listener_force_free(channel_listener_t *chan_l) { tor_assert(chan_l); + log_debug(LD_CHANNEL, + "Force-freeing channel_listener_t " U64_FORMAT " at %p", + U64_PRINTF_ARG(chan_l->global_identifier), + chan_l); + /* Call a free method if there is one */ if (chan_l->free) chan_l->free(chan_l); -- cgit v1.2.3-54-g00ecf From ac227cf587c17fb2bdd10de4b320ea4df3632cd8 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Mon, 15 Oct 2012 11:37:14 -0700 Subject: Close and free channel_tls_listener correctly in channel_tls_free_all() --- src/or/channeltls.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/or/channeltls.c b/src/or/channeltls.c index 1a2956b755..62bb18bb8d 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, -- cgit v1.2.3-54-g00ecf