From 0ce53ca8171f8be57354951b6e92a4feea300729 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 4 May 2007 10:34:47 +0000 Subject: [PATCH] on the theory that my client_used hack is here to stay at least for the next little while, make it only take effect _when there's an attached origin circuit_, rather than from the first attached origin circuit until death of the conn. svn:r10116 --- src/or/circuitlist.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 07fca3d156..5580bd0394 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -74,9 +74,10 @@ orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL; /** Implementation helper for circuit_set_{p,n}_circid_orconn: A circuit ID * and/or or_connection for circ has just changed from old_conn, old_id * to conn, id. Adjust the conn,circid map as appropriate, removing - * the old entry (if any) and adding a new one. If If active is true, + * the old entry (if any) and adding a new one. If active is true, * remove the circuit from the list of active circuits on old_conn and add it - * to the list of active circuits on conn. */ + * to the list of active circuits on conn. + * XXX "active" isn't an arg anymore */ static void circuit_set_circid_orconn_helper(circuit_t *circ, int direction, uint16_t id, @@ -896,6 +897,22 @@ circuit_expire_all_dirty_circs(void) } } +/** Return 1 if there are any origin circuits that use + * conn as there first hop. Else return 0. */ +static int +circuit_any_origin_circs_on_conn(or_connection_t *conn) +{ + circuit_t *circ; + + for (circ=global_circuitlist; circ; circ = circ->next) { + if (CIRCUIT_IS_ORIGIN(circ) && + !circ->marked_for_close && + circ->n_conn == conn) + return 1; + } + return 0; +} + /** Mark circ to be closed next time we call * circuit_close_all_marked(). Do any cleanup needed: * - If state is onionskin_pending, remove circ from the onion_pending @@ -1020,7 +1037,12 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line, circ->marked_for_close = line; circ->marked_for_close_file = file; - if (! CIRCUIT_IS_ORIGIN(circ)) { + if (CIRCUIT_IS_ORIGIN(circ)) { + if (circ->n_conn && circ->n_conn->client_used) { + circ->n_conn->client_used = + circuit_any_origin_circs_on_conn(circ->n_conn); + } + } else { or_circuit_t *or_circ = TO_OR_CIRCUIT(circ); if (or_circ->rend_splice) { if (!or_circ->rend_splice->_base.marked_for_close) {