diff options
author | Andrea Shepard <andrea@torproject.org> | 2012-10-01 13:06:10 -0700 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2012-10-10 00:44:46 -0700 |
commit | 3d092ffbdd023a2be0307cb8a52bd48e2c85b257 (patch) | |
tree | 64042f37575714c4f2b2b9c6a280ff60b3dc90e2 /src/or/circuitlist.c | |
parent | 6830c9c232ff8d93461d18aa4fc729861804e00e (diff) | |
download | tor-3d092ffbdd023a2be0307cb8a52bd48e2c85b257.tar.gz tor-3d092ffbdd023a2be0307cb8a52bd48e2c85b257.zip |
Handle closing circuits correctly with circuitmux_t
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r-- | src/or/circuitlist.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index a4dcec68a2..a87f989f34 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -131,11 +131,12 @@ circuit_set_circid_chan_helper(circuit_t *circ, int direction, if (old_chan) { /* * If we're changing channels or ID and had an old channel and a non - * zero old ID (i.e., we should have been attached), detach the circuit. - * ID changes require this because circuitmux hashes on (channel_id, - * circuit_id). + * zero old ID and weren't marked for close (i.e., we should have been + * attached), detach the circuit. ID changes require this because + * circuitmux hashes on (channel_id, circuit_id). */ - if (id != 0 && (old_chan != chan || old_id != id)) { + if (id != 0 && (old_chan != chan || old_id != id) && + !(circ->marked_for_close)) { tor_assert(old_chan->cmux); circuitmux_detach_circuit(old_chan->cmux, circ); } @@ -180,9 +181,11 @@ circuit_set_circid_chan_helper(circuit_t *circ, int direction, /* * Attach to the circuitmux if we're changing channels or IDs and - * have a new channel and ID to use. + * have a new channel and ID to use and the circuit is not marked for + * close. */ - if (chan && id != 0 && (old_chan != chan || old_id != id)) { + if (chan && id != 0 && (old_chan != chan || old_id != id) && + !(circ->marked_for_close)) { tor_assert(chan->cmux); circuitmux_attach_circuit(chan->cmux, circ, direction); attached = 1; @@ -1398,6 +1401,7 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line, if (circ->n_chan) { circuit_clear_cell_queue(circ, circ->n_chan); channel_send_destroy(circ->n_circ_id, circ->n_chan, reason); + circuitmux_detach_circuit(circ->n_chan->cmux, circ); } if (! CIRCUIT_IS_ORIGIN(circ)) { @@ -1425,6 +1429,7 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line, if (or_circ->p_chan) { circuit_clear_cell_queue(circ, or_circ->p_chan); channel_send_destroy(or_circ->p_circ_id, or_circ->p_chan, reason); + circuitmux_detach_circuit(or_circ->p_chan->cmux, circ); } } else { origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ); |