From 1a74360c2dd5c197e2dfc28b37961c77bb7792f1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 9 Sep 2013 13:48:44 -0400 Subject: 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. --- src/or/circuitmux.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/or/circuitmux.c') 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 detached_out 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, -- cgit v1.2.3