summaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-04-10 16:24:50 +0000
committerNick Mathewson <nickm@torproject.org>2007-04-10 16:24:50 +0000
commitf95d232483a0e9fd78563bfdc061016baab6ef97 (patch)
tree7cb29766f595c542221a3d0a354f55daa6123794 /src/or/circuitlist.c
parent58a6761056af4c5f50e9550f50625e91e55b30a1 (diff)
downloadtor-f95d232483a0e9fd78563bfdc061016baab6ef97.tar.gz
tor-f95d232483a0e9fd78563bfdc061016baab6ef97.zip
r12332@catbus: nickm | 2007-04-10 12:24:45 -0400
Yet another attempted Bug 411 fix: Under some circumstances, a circuit can have cells without being active. The likeliest is that it has been unlinked from all connections in preparation for closing. Therefore, stop enforcing this non-invariant. svn:r9936
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 4f8b17d8b3..73ca7e1fa0 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -80,21 +80,25 @@ orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL;
static void
circuit_set_circid_orconn_helper(circuit_t *circ, int direction,
uint16_t id,
- or_connection_t *conn,
- int active)
+ or_connection_t *conn)
{
orconn_circid_circuit_map_t search;
orconn_circid_circuit_map_t *found;
or_connection_t *old_conn, **conn_ptr;
uint16_t old_id, *circid_ptr;
+ int was_active, make_active;
if (direction == CELL_DIRECTION_OUT) {
conn_ptr = &circ->n_conn;
circid_ptr = &circ->n_circ_id;
+ was_active = circ->next_active_on_n_conn != NULL;
+ make_active = circ->n_conn_cells.n > 0;
} else {
or_circuit_t *c = TO_OR_CIRCUIT(circ);
conn_ptr = &c->p_conn;
circid_ptr = &c->p_circ_id;
+ was_active = c->next_active_on_p_conn != NULL;
+ make_active = c->p_conn_cells.n > 0;
}
old_conn = *conn_ptr;
old_id = *circid_ptr;
@@ -119,7 +123,7 @@ circuit_set_circid_orconn_helper(circuit_t *circ, int direction,
tor_free(found);
--old_conn->n_circuits;
}
- if (active && old_conn != conn)
+ if (was_active && old_conn != conn)
make_circuit_inactive_on_conn(circ,old_conn);
}
@@ -144,7 +148,7 @@ circuit_set_circid_orconn_helper(circuit_t *circ, int direction,
found->circuit = circ;
HT_INSERT(orconn_circid_map, &orconn_circid_circuit_map, found);
}
- if (active && old_conn != conn)
+ if (make_active && old_conn != conn)
make_circuit_active_on_conn(circ,conn);
++conn->n_circuits;
@@ -157,15 +161,11 @@ void
circuit_set_p_circid_orconn(or_circuit_t *circ, uint16_t id,
or_connection_t *conn)
{
- int active = circ->p_conn_cells.n > 0;
-
- tor_assert(bool_eq(active, circ->next_active_on_p_conn));
-
circuit_set_circid_orconn_helper(TO_CIRCUIT(circ), CELL_DIRECTION_IN,
- id, conn, active);
+ id, conn);
if (conn)
- tor_assert(bool_eq(active, circ->next_active_on_p_conn));
+ tor_assert(bool_eq(circ->p_conn_cells.n, circ->next_active_on_p_conn));
}
/** Set the n_conn field of a circuit <b>circ</b>, along
@@ -175,15 +175,10 @@ void
circuit_set_n_circid_orconn(circuit_t *circ, uint16_t id,
or_connection_t *conn)
{
- int active = circ->n_conn_cells.n > 0;
-
- tor_assert(bool_eq(active, circ->next_active_on_n_conn));
-
- circuit_set_circid_orconn_helper(circ, CELL_DIRECTION_OUT,
- id, conn, active);
+ circuit_set_circid_orconn_helper(circ, CELL_DIRECTION_OUT, id, conn);
if (conn)
- tor_assert(bool_eq(active, circ->next_active_on_n_conn));
+ tor_assert(bool_eq(circ->n_conn_cells.n, circ->next_active_on_n_conn));
}
/** Change the state of <b>circ</b> to <b>state</b>, adding it to or removing