diff options
author | Roger Dingledine <arma@torproject.org> | 2010-09-28 22:32:38 -0400 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2010-09-28 22:32:38 -0400 |
commit | 9997676802c140aceddb849090c7b3795fc83361 (patch) | |
tree | 66cdff441b840e2405f146bc6b32a37cce35849a /src/or/connection_or.c | |
parent | 7de1caa33f025db5474dba5f7e256d28c5ab4969 (diff) | |
download | tor-9997676802c140aceddb849090c7b3795fc83361.tar.gz tor-9997676802c140aceddb849090c7b3795fc83361.zip |
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.
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 16 |
1 files changed, 10 insertions, 6 deletions
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 <b>digest</b> is non-NULL, just + * the OR connections with that digest), and set the is_bad_for_new_circs * flag on: + * - all connections if <b>force</b> 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; } |