Use circuit_get_by_circid_channel_even_if_marked() and fix some asserts in circuitmux.c

This commit is contained in:
Andrea Shepard 2012-10-01 14:25:52 -07:00
parent 1498a6e84a
commit a0200c1f6e

View file

@ -130,8 +130,6 @@ struct chanid_circid_muxinfo_t {
* Internal-use #defines
*/
#define CMUX_PARANOIA
#ifdef CMUX_PARANOIA
#define circuitmux_assert_okay_paranoid(cmux) \
circuitmux_assert_okay(cmux)
@ -341,7 +339,11 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
circuit_t *circ = NULL;
tor_assert(cmux);
circuitmux_assert_okay_paranoid(cmux);
/*
* Don't circuitmux_assert_okay_paranoid() here; this gets called when
* channels are being freed and have already been unregistered, so
* the channel ID lookups it does will fail.
*/
i = HT_START(chanid_circid_muxinfo_map, cmux->chanid_circid_map);
while (i) {
@ -351,7 +353,9 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
/* Find a channel and circuit */
chan = channel_find_by_global_id(to_remove->chan_id);
if (chan) {
circ = circuit_get_by_circid_channel(to_remove->circ_id, chan);
circ =
circuit_get_by_circid_channel_even_if_marked(to_remove->circ_id,
chan);
if (circ) {
/* Clear the circuit's mux for this direction */
if (to_remove->muxinfo.direction == CELL_DIRECTION_OUT) {
@ -552,7 +556,7 @@ circuitmux_set_policy(circuitmux_t *cmux,
tor_assert(chan);
/* Get the circuit */
circ = circuit_get_by_circid_channel((*i)->circ_id, chan);
circ = circuit_get_by_circid_channel_even_if_marked((*i)->circ_id, chan);
tor_assert(circ);
/* Need to tell old policy it becomes inactive (i.e., it is active) ? */
@ -1477,8 +1481,8 @@ circuitmux_assert_okay_pass_one(circuitmux_t *cmux)
/* Find the channel and circuit, assert that they exist */
chan = channel_find_by_global_id(chan_id);
tor_assert(chan);
circ = circuit_get_by_circid_channel(circ_id, chan);
if (circ) {
circ = circuit_get_by_circid_channel_even_if_marked(circ_id, chan);
tor_assert(circ);
/* Clear the circ_is_active bit to start */
circ_is_active = 0;
@ -1525,17 +1529,6 @@ circuitmux_assert_okay_pass_one(circuitmux_t *cmux)
tor_assert(circ != cmux->active_circuits_head);
tor_assert(circ != cmux->active_circuits_tail);
}
} else {
/*
* circuit_get_by_circid_channel() doesn't want us to have a circuit
* that's marked for close, but we can test for that case with
* circuit_id_in_use_on_channel(). Assert if it really, really isn't
* there.
*/
tor_assert(circuit_id_in_use_on_channel(circ_id, chan));
/* It definitely isn't active */
circ_is_active = 0;
}
/* Increment the circuits counter */
++n_circuits;