aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-03-26 14:07:59 +0000
committerNick Mathewson <nickm@torproject.org>2007-03-26 14:07:59 +0000
commit38c0bb3a99956a0ff2e570bd8f2b900d46741992 (patch)
tree9a447e7b431abdc819d3ba1f30755f5b40678c79 /src/or/circuitlist.c
parent6e51bdd5e4d5ab39fc1dca12e468b9a1c573cc1b (diff)
downloadtor-38c0bb3a99956a0ff2e570bd8f2b900d46741992.tar.gz
tor-38c0bb3a99956a0ff2e570bd8f2b900d46741992.zip
r12651@Kushana: nickm | 2007-03-24 18:26:42 -0400
Initial version of circuit-based cell queues. Instead of hammering or_conns with piles of cells, queue cells on their corresponding circuits, and append them to the or_conn as needed. This seems to work so far, but needs a bit more work. This will break the memory-use-limitation patch for begin_dir conns: the solution will be a fun but fiddly. svn:r9904
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 8ed5c16a98..f76d2cba1b 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -71,10 +71,12 @@ HT_GENERATE(orconn_circid_map, orconn_circid_circuit_map_t, node,
*/
orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL;
+/** DOCDOC */
static void
circuit_set_circid_orconn_helper(circuit_t *circ, uint16_t id,
or_connection_t *conn,
- uint16_t old_id, or_connection_t *old_conn)
+ uint16_t old_id, or_connection_t *old_conn,
+ int active)
{
orconn_circid_circuit_map_t search;
orconn_circid_circuit_map_t *found;
@@ -96,6 +98,8 @@ circuit_set_circid_orconn_helper(circuit_t *circ, uint16_t id,
tor_free(found);
--old_conn->n_circuits;
}
+ if (active)
+ make_circuit_inactive_on_conn(circ,old_conn);
}
if (conn == NULL)
@@ -114,6 +118,9 @@ circuit_set_circid_orconn_helper(circuit_t *circ, uint16_t id,
found->circuit = circ;
HT_INSERT(orconn_circid_map, &orconn_circid_circuit_map, found);
}
+ if (active)
+ make_circuit_active_on_conn(circ,conn);
+
++conn->n_circuits;
}
@@ -126,16 +133,18 @@ circuit_set_p_circid_orconn(or_circuit_t *circ, uint16_t id,
{
uint16_t old_id;
or_connection_t *old_conn;
+ int active;
old_id = circ->p_circ_id;
old_conn = circ->p_conn;
circ->p_circ_id = id;
circ->p_conn = conn;
+ active = circ->p_conn_cells.n > 0;
if (id == old_id && conn == old_conn)
return;
circuit_set_circid_orconn_helper(TO_CIRCUIT(circ), id, conn,
- old_id, old_conn);
+ old_id, old_conn, active);
}
/** Set the n_conn field of a circuit <b>circ</b>, along
@@ -147,15 +156,17 @@ circuit_set_n_circid_orconn(circuit_t *circ, uint16_t id,
{
uint16_t old_id;
or_connection_t *old_conn;
+ int active;
old_id = circ->n_circ_id;
old_conn = circ->n_conn;
circ->n_circ_id = id;
circ->n_conn = conn;
+ active = circ->n_conn_cells.n > 0;
if (id == old_id && conn == old_conn)
return;
- circuit_set_circid_orconn_helper(circ, id, conn, old_id, old_conn);
+ circuit_set_circid_orconn_helper(circ, id, conn, old_id, old_conn, active);
}
/** Change the state of <b>circ</b> to <b>state</b>, adding it to or removing
@@ -380,12 +391,16 @@ circuit_free(circuit_t *circ)
other->rend_splice = NULL;
}
+ cell_queue_clear(&ocirc->p_conn_cells);
+
tor_free(circ->onionskin);
/* remove from map. */
circuit_set_p_circid_orconn(ocirc, 0, NULL);
}
+ cell_queue_clear(&circ->n_conn_cells);
+
/* Remove from map. */
circuit_set_n_circid_orconn(circ, 0, NULL);
@@ -637,6 +652,9 @@ void
circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason)
{
circuit_t *circ;
+
+ connection_or_unlink_all_active_circs(conn);
+
for (circ = global_circuitlist; circ; circ = circ->next) {
int mark = 0;
if (circ->n_conn == conn) {