aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index cf6020de06..bec3dc8175 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -134,10 +134,20 @@ circuit_set_circid_chan_helper(circuit_t *circ, int direction,
found = HT_REMOVE(chan_circid_map, &chan_circid_map, &search);
if (found) {
tor_free(found);
- --old_chan->n_circuits;
+ if (direction == CELL_DIRECTION_OUT) {
+ /* One fewer circuits use old_chan as n_chan */
+ --(old_chan->num_n_circuits);
+ } else {
+ /* One fewer circuits use old_chan as p_chan */
+ --(old_chan->num_p_circuits);
+ }
+ }
+
+ /* If we're changing channels, detach the circuit */
+ if (old_chan != chan) {
+ tor_assert(old_chan->cmux);
+ circuitmux_detach_circuit(old_chan->cmux, circ);
}
- if (was_active && old_chan != chan)
- make_circuit_inactive_on_chan(circ, old_chan);
}
/* Change the values only after we have possibly made the circuit inactive
@@ -161,10 +171,26 @@ circuit_set_circid_chan_helper(circuit_t *circ, int direction,
found->circuit = circ;
HT_INSERT(chan_circid_map, &chan_circid_map, found);
}
+
+ /* Attach to the circuitmux if we're changing channels */
+ if (old_chan != chan) {
+ tor_assert(chan->cmux);
+ circuitmux_attach_circuit(chan->cmux, circ, direction);
+ }
+
+ /*
+ * This is a no-op if we have no cells, but if we do it marks us active to
+ * the circuitmux
+ */
if (make_active && old_chan != chan)
- make_circuit_active_on_chan(circ,chan);
+ update_circuit_on_cmux(circ, direction);
- ++chan->n_circuits;
+ /* Adjust circuit counts on new channel */
+ if (direction == CELL_DIRECTION_OUT) {
+ ++chan->num_n_circuits;
+ } else {
+ ++chan->num_p_circuits;
+ }
}
/** Set the p_conn field of a circuit <b>circ</b>, along
@@ -994,7 +1020,7 @@ circuit_unlink_all_from_channel(channel_t *chan, int reason)
{
circuit_t *circ;
- channel_unlink_all_active_circs(chan);
+ channel_unlink_all_circuits(chan);
for (circ = global_circuitlist; circ; circ = circ->next) {
int mark = 0;