aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-18 14:50:59 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-18 14:50:59 +0000
commit5ff0e4ed567e70777adb0d590fd68325e4edca75 (patch)
tree49f026d4289b26fd427b6cec264411c018464ae0 /src/or/routerlist.c
parent192e3d71d44335e35a95dbe08425a796f59e2215 (diff)
downloadtor-5ff0e4ed567e70777adb0d590fd68325e4edca75.tar
tor-5ff0e4ed567e70777adb0d590fd68325e4edca75.tar.gz
r15917@catbus: nickm | 2007-10-18 10:50:01 -0400
Better log messages about extrainfo downloads. svn:r12023
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index cea82a5b6..fdd7d04c0 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3771,24 +3771,6 @@ update_router_descriptor_downloads(time_t now)
update_consensus_router_descriptor_downloads(now);
}
-/** Return true iff <b>sd</b> is the descriptor for a router descriptor that
- * has an extrainfo that we don't currently have, are not currently
- * downloading, and have not recently tried to download. */
-static INLINE int
-should_download_extrainfo(signed_descriptor_t *sd,
- const routerlist_t *rl,
- const digestmap_t *pending,
- time_t now)
-{
- const char *d = sd->extra_info_digest;
- return (!sd->is_extrainfo &&
- !tor_digest_is_zero(d) &&
- download_status_is_ready(&sd->ei_dl_status, now,
- MAX_ROUTERDESC_DOWNLOAD_FAILURES) &&
- !eimap_get(rl->extra_info_map, d) &&
- !digestmap_get(pending, d));
-}
-
/** Launch extrainfo downloads as needed. */
void
update_extrainfo_downloads(time_t now)
@@ -3797,7 +3779,8 @@ update_extrainfo_downloads(time_t now)
routerlist_t *rl;
smartlist_t *wanted;
digestmap_t *pending;
- int i;
+ int old_routers, i;
+ int n_no_ei = 0, n_pending = 0, n_have = 0, n_delay = 0;
if (! options->DownloadExtraInfo)
return;
if (should_delay_dir_fetches(options))
@@ -3807,20 +3790,44 @@ update_extrainfo_downloads(time_t now)
list_pending_descriptor_downloads(pending, 1);
rl = router_get_routerlist();
wanted = smartlist_create();
- SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
- if (should_download_extrainfo(&ri->cache_info, rl, pending, now)) {
- smartlist_add(wanted, ri->cache_info.extra_info_digest);
+ for (old_routers = 0; old_routers < 2; ++old_routers) {
+ smartlist_t *lst = old_routers ? rl->old_routers : rl->routers;
+ for (i = 0; i < smartlist_len(lst); ++i) {
+ signed_descriptor_t *sd;
+ char *d;
+ if (old_routers)
+ sd = smartlist_get(lst, i);
+ else
+ sd = &((routerinfo_t*)smartlist_get(lst, i))->cache_info;
+ if (sd->is_extrainfo)
+ continue; /* This should never happen. */
+ d = sd->extra_info_digest;
+ if (tor_digest_is_zero(d)) {
+ ++n_no_ei;
+ continue;
}
- });
- if (dirserver_mode(options)) {
- SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd, {
- if (should_download_extrainfo(sd, rl, pending, now)) {
- smartlist_add(wanted, sd->extra_info_digest);
- }
- });
+ if (eimap_get(rl->extra_info_map, d)) {
+ ++n_have;
+ continue;
+ }
+ if (!download_status_is_ready(&sd->ei_dl_status, now,
+ MAX_ROUTERDESC_DOWNLOAD_FAILURES)) {
+ ++n_delay;
+ continue;
+ }
+ if (digestmap_get(pending, d)) {
+ ++n_pending;
+ continue;
+ }
+ smartlist_add(wanted, d);
+ }
}
digestmap_free(pending, NULL);
+ log_info(LD_DIR, "Extrainfo download status: %d router with no ei, %d "
+ "with present ei, %d delaying, %d pending, %d downloadable.",
+ n_no_ei, n_have, n_delay, n_pending, smartlist_len(wanted));
+
smartlist_shuffle(wanted);
for (i = 0; i < smartlist_len(wanted); i += MAX_DL_PER_REQUEST) {
initiate_descriptor_downloads(NULL, DIR_PURPOSE_FETCH_EXTRAINFO,