From 9997676802c140aceddb849090c7b3795fc83361 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 28 Sep 2010 22:32:38 -0400 Subject: handle ugly edge case in retrying entrynodes Specifically, a circ attempt that we'd launched while the network was down could timeout after we've marked our entrynodes up, marking them back down again. The fix is to annotate as bad the OR conns that were around before we did the retry, so if a circuit that's attached to them times out we don't do anything about it. --- src/or/connection_or.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/or/connection_or.c') diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 6b648b124d..836e7faef5 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -610,7 +610,7 @@ connection_or_get_for_extend(const char *digest, * appropriate. Helper for connection_or_set_bad_connections(). */ static void -connection_or_group_set_badness(or_connection_t *head) +connection_or_group_set_badness(or_connection_t *head, int force) { or_connection_t *or_conn = NULL, *best = NULL; int n_old = 0, n_inprogress = 0, n_canonical = 0, n_other = 0; @@ -622,8 +622,9 @@ connection_or_group_set_badness(or_connection_t *head) if (or_conn->_base.marked_for_close || or_conn->is_bad_for_new_circs) continue; - if (or_conn->_base.timestamp_created + TIME_BEFORE_OR_CONN_IS_TOO_OLD - < now) { + if (force || + or_conn->_base.timestamp_created + TIME_BEFORE_OR_CONN_IS_TOO_OLD + < now) { log_info(LD_OR, "Marking OR conn to %s:%d as too old for new circuits " "(fd %d, %d secs old).", @@ -718,8 +719,10 @@ connection_or_group_set_badness(or_connection_t *head) } } -/** Go through all the OR connections, and set the is_bad_for_new_circs +/** Go through all the OR connections (or if digest is non-NULL, just + * the OR connections with that digest), and set the is_bad_for_new_circs * flag on: + * - all connections if force is true. * - all connections that are too old. * - all open non-canonical connections for which a canonical connection * exists to the same router. @@ -732,13 +735,14 @@ connection_or_group_set_badness(or_connection_t *head) * better than another. */ void -connection_or_set_bad_connections(void) +connection_or_set_bad_connections(const char *digest, int force) { if (!orconn_identity_map) return; DIGESTMAP_FOREACH(orconn_identity_map, identity, or_connection_t *, conn) { - connection_or_group_set_badness(conn); + if (!digest || !memcmp(digest, conn->identity_digest, DIGEST_LEN)) + connection_or_group_set_badness(conn, force); } DIGESTMAP_FOREACH_END; } -- cgit v1.2.3-54-g00ecf