From dfc6555ddd959ac8648ee7c1b598a71d5b09453c Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Wed, 31 Dec 2008 14:19:57 +0000 Subject: [PATCH] switch over the bridge descriptor download mechanism to use the same download mechanism as other places. i had to make an ugly hack around "IMPOSSIBLE_TO_DOWNLOAD+1". we should unhack that sometime. svn:r17834 --- src/or/circuitbuild.c | 32 +++++--------------------------- src/or/rendcommon.c | 2 +- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 17977ab07a..8c64f68f7b 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2980,35 +2980,12 @@ bridge_add_from_config(const tor_addr_t *addr, uint16_t port, char *digest) b->port = port; if (digest) memcpy(b->identity, digest, DIGEST_LEN); + b->fetch_status.schedule = DL_SCHED_BRIDGE; if (!bridge_list) bridge_list = smartlist_create(); smartlist_add(bridge_list, b); } -/** Schedule the next fetch for bridge, based on - * some retry schedule. */ -static void -bridge_fetch_status_increment(bridge_info_t *bridge, time_t now) -{ - switch (bridge->fetch_status.n_download_failures) { - case 0: bridge->fetch_status.next_attempt_at = now+60*15; break; - case 1: bridge->fetch_status.next_attempt_at = now+60*15; break; - default: bridge->fetch_status.next_attempt_at = now+60*60; break; - } - if (bridge->fetch_status.n_download_failures < 10) - bridge->fetch_status.n_download_failures++; -} - -/** We just got a new descriptor for bridge. Reschedule the - * next fetch for a long time from now. */ -static void -bridge_fetch_status_arrived(bridge_info_t *bridge, time_t now) -{ - tor_assert(bridge); - bridge->fetch_status.next_attempt_at = now+60*60; - bridge->fetch_status.n_download_failures = 0; -} - /** If digest is one of our known bridges, return it. */ static bridge_info_t * find_bridge_by_digest(const char *digest) @@ -3072,11 +3049,12 @@ fetch_bridge_descriptors(time_t now) SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, bridge) { - if (bridge->fetch_status.next_attempt_at > now) + if (!download_status_is_ready(&bridge->fetch_status, now, + IMPOSSIBLE_TO_DOWNLOAD+1)) continue; /* don't bother, no need to retry yet */ /* schedule another fetch as if this one will fail, in case it does */ - bridge_fetch_status_increment(bridge, now); + download_status_failed(&bridge->fetch_status, 0); can_use_bridge_authority = !tor_digest_is_zero(bridge->identity) && num_bridge_auths; @@ -3136,7 +3114,7 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache) if (bridge) { /* if we actually want to use this one */ /* it's here; schedule its re-fetch for a long time from now. */ if (!from_cache) - bridge_fetch_status_arrived(bridge, now); + download_status_reset(&bridge->fetch_status); add_an_entry_guard(ri, 1); log_notice(LD_DIR, "new bridge descriptor '%s' (%s)", ri->nickname, diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 5e73b3830a..f81cfed6a1 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -696,7 +696,7 @@ rend_encode_service_descriptor(rend_service_descriptor_t *desc, intro->extend_info->identity_digest, DIGEST_LEN); tor_assert(strlen(ipoint) == ipoint_len); - /* Assert that appending ipoint and its NUL won't over overun the + /* Assert that appending ipoint and its NUL won't over overrun the * buffer. */ tor_assert(cp + ipoint_len+1 < *str_out + buflen); memcpy(cp, ipoint, ipoint_len+1);