summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@persephoneslair.org>2012-10-15 07:22:33 -0700
committerAndrea Shepard <andrea@persephoneslair.org>2012-10-15 07:22:33 -0700
commit4da2864308efd3de7a3dcc857003fa4aea169be6 (patch)
tree4e3bb117c5308ebf7c5099355d925205cba49aaf
parent0d946e1773da2a7cf5fa22ff9c62700985b26f7f (diff)
parent3894ca15080e48bc025333df494ab211168c94da (diff)
downloadtor-4da2864308efd3de7a3dcc857003fa4aea169be6.tar.gz
tor-4da2864308efd3de7a3dcc857003fa4aea169be6.zip
Merge branch 'bug7087' of git://git.torproject.org/user/andrea/tor
-rw-r--r--src/or/channel.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/or/channel.c b/src/or/channel.c
index 6527288c4a..2642431267 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -808,11 +808,24 @@ channel_free(channel_t *chan)
/* It must be deregistered */
tor_assert(!(chan->registered));
+ log_debug(LD_CHANNEL,
+ "Freeing channel " U64_FORMAT " at %p",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+
+ /*
+ * Get rid of cmux policy before we do anything, so cmux policies don't
+ * see channels in weird half-freed states.
+ */
+ if (chan->cmux) {
+ circuitmux_set_policy(chan->cmux, NULL);
+ }
+
/* Call a free method if there is one */
if (chan->free) chan->free(chan);
channel_clear_remote_end(chan);
+ /* Get rid of cmux */
if (chan->cmux) {
circuitmux_detach_all_circuits(chan->cmux);
circuitmux_free(chan->cmux);
@@ -863,11 +876,29 @@ channel_force_free(channel_t *chan)
{
tor_assert(chan);
+ log_debug(LD_CHANNEL,
+ "Force-freeing channel " U64_FORMAT " at %p",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+
+ /*
+ * Get rid of cmux policy before we do anything, so cmux policies don't
+ * see channels in weird half-freed states.
+ */
+ if (chan->cmux) {
+ circuitmux_set_policy(chan->cmux, NULL);
+ }
+
/* Call a free method if there is one */
if (chan->free) chan->free(chan);
channel_clear_remote_end(chan);
+ /* Get rid of cmux */
+ if (chan->cmux) {
+ circuitmux_free(chan->cmux);
+ chan->cmux = NULL;
+ }
+
/* We might still have a cell queue; kill it */
if (chan->incoming_queue) {
SMARTLIST_FOREACH_BEGIN(chan->incoming_queue,