mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Use circuit_get_by_circid_channel_even_if_marked() and fix some asserts in circuitmux.c
This commit is contained in:
parent
1498a6e84a
commit
a0200c1f6e
1 changed files with 53 additions and 60 deletions
|
@ -130,8 +130,6 @@ struct chanid_circid_muxinfo_t {
|
||||||
* Internal-use #defines
|
* Internal-use #defines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CMUX_PARANOIA
|
|
||||||
|
|
||||||
#ifdef CMUX_PARANOIA
|
#ifdef CMUX_PARANOIA
|
||||||
#define circuitmux_assert_okay_paranoid(cmux) \
|
#define circuitmux_assert_okay_paranoid(cmux) \
|
||||||
circuitmux_assert_okay(cmux)
|
circuitmux_assert_okay(cmux)
|
||||||
|
@ -341,7 +339,11 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
|
||||||
circuit_t *circ = NULL;
|
circuit_t *circ = NULL;
|
||||||
|
|
||||||
tor_assert(cmux);
|
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);
|
i = HT_START(chanid_circid_muxinfo_map, cmux->chanid_circid_map);
|
||||||
while (i) {
|
while (i) {
|
||||||
|
@ -351,7 +353,9 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
|
||||||
/* Find a channel and circuit */
|
/* Find a channel and circuit */
|
||||||
chan = channel_find_by_global_id(to_remove->chan_id);
|
chan = channel_find_by_global_id(to_remove->chan_id);
|
||||||
if (chan) {
|
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) {
|
if (circ) {
|
||||||
/* Clear the circuit's mux for this direction */
|
/* Clear the circuit's mux for this direction */
|
||||||
if (to_remove->muxinfo.direction == CELL_DIRECTION_OUT) {
|
if (to_remove->muxinfo.direction == CELL_DIRECTION_OUT) {
|
||||||
|
@ -552,7 +556,7 @@ circuitmux_set_policy(circuitmux_t *cmux,
|
||||||
tor_assert(chan);
|
tor_assert(chan);
|
||||||
|
|
||||||
/* Get the circuit */
|
/* 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);
|
tor_assert(circ);
|
||||||
|
|
||||||
/* Need to tell old policy it becomes inactive (i.e., it is active) ? */
|
/* 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 */
|
/* Find the channel and circuit, assert that they exist */
|
||||||
chan = channel_find_by_global_id(chan_id);
|
chan = channel_find_by_global_id(chan_id);
|
||||||
tor_assert(chan);
|
tor_assert(chan);
|
||||||
circ = circuit_get_by_circid_channel(circ_id, chan);
|
circ = circuit_get_by_circid_channel_even_if_marked(circ_id, chan);
|
||||||
if (circ) {
|
tor_assert(circ);
|
||||||
/* Clear the circ_is_active bit to start */
|
/* Clear the circ_is_active bit to start */
|
||||||
circ_is_active = 0;
|
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_head);
|
||||||
tor_assert(circ != cmux->active_circuits_tail);
|
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 */
|
/* Increment the circuits counter */
|
||||||
++n_circuits;
|
++n_circuits;
|
||||||
|
|
Loading…
Add table
Reference in a new issue