aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitmux.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-09-09 13:48:44 -0400
committerNick Mathewson <nickm@torproject.org>2014-03-14 11:57:51 -0400
commit1a74360c2dd5c197e2dfc28b37961c77bb7792f1 (patch)
treed1e856ff67b9dcf2a97fabaaea5fc599566a62d6 /src/or/circuitmux.c
parent102bb1c04f5cb4fb3eae7f41f80660e47c64ceb6 (diff)
downloadtor-1a74360c2dd5c197e2dfc28b37961c77bb7792f1.tar
tor-1a74360c2dd5c197e2dfc28b37961c77bb7792f1.tar.gz
Test code for implementation of faster circuit_unlink_all_from_channel
This contains the obvious implementation using the circuitmux data structure. It also runs the old (slow) algorithm and compares the results of the two to make sure that they're the same. Needs review and testing.
Diffstat (limited to 'src/or/circuitmux.c')
-rw-r--r--src/or/circuitmux.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index f2af94393..2d05c748e 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -390,10 +390,13 @@ circuitmux_alloc(void)
/**
* Detach all circuits from a circuitmux (use before circuitmux_free())
+ *
+ * If <b>detached_out</b> is non-NULL, add every detached circuit_t to
+ * detached_out.
*/
void
-circuitmux_detach_all_circuits(circuitmux_t *cmux)
+circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out)
{
chanid_circid_muxinfo_t **i = NULL, *to_remove;
channel_t *chan = NULL;
@@ -430,6 +433,9 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
/* Clear n_mux */
circ->n_mux = NULL;
+
+ if (detached_out)
+ smartlist_add(detached_out, circ);
} else if (circ->magic == OR_CIRCUIT_MAGIC) {
/*
* Update active_circuits et al.; this does policy notifies, so
@@ -445,6 +451,9 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
* so clear p_mux.
*/
TO_OR_CIRCUIT(circ)->p_mux = NULL;
+
+ if (detached_out)
+ smartlist_add(detached_out, circ);
} else {
/* Complain and move on */
log_warn(LD_CIRC,