diff options
author | Roger Dingledine <arma@torproject.org> | 2008-12-31 14:19:57 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2008-12-31 14:19:57 +0000 |
commit | dfc6555ddd959ac8648ee7c1b598a71d5b09453c (patch) | |
tree | f7a321012228c72371be0caac4ec2addc74a70ed | |
parent | 9ea7e7f0cd33d06d64e4bae87272fce07889ff9d (diff) | |
download | tor-dfc6555ddd959ac8648ee7c1b598a71d5b09453c.tar tor-dfc6555ddd959ac8648ee7c1b598a71d5b09453c.tar.gz |
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
-rw-r--r-- | src/or/circuitbuild.c | 32 | ||||
-rw-r--r-- | 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 17977ab07..8c64f68f7 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 <b>bridge</b>, 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 <b>bridge</b>. Reschedule the - * next fetch for a long time from <b>now</b>. */ -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 <b>digest</b> 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 5e73b3830..f81cfed6a 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); |