[or-cvs] r17834: {tor} switch over the bridge descriptor download mechanism to use (tor/trunk/src/or)
arma at seul.org
arma at seul.org
Wed Dec 31 14:19:57 UTC 2008
Author: arma
Date: 2008-12-31 09:19:57 -0500 (Wed, 31 Dec 2008)
New Revision: 17834
Modified:
tor/trunk/src/or/circuitbuild.c
tor/trunk/src/or/rendcommon.c
Log:
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.
Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c 2008-12-31 14:11:46 UTC (rev 17833)
+++ tor/trunk/src/or/circuitbuild.c 2008-12-31 14:19:57 UTC (rev 17834)
@@ -2980,35 +2980,12 @@
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 @@
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 @@
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,
Modified: tor/trunk/src/or/rendcommon.c
===================================================================
--- tor/trunk/src/or/rendcommon.c 2008-12-31 14:11:46 UTC (rev 17833)
+++ tor/trunk/src/or/rendcommon.c 2008-12-31 14:19:57 UTC (rev 17834)
@@ -696,7 +696,7 @@
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);
More information about the tor-commits
mailing list