mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
r15917@catbus: nickm | 2007-10-18 10:50:01 -0400
Better log messages about extrainfo downloads. svn:r12023
This commit is contained in:
parent
192e3d71d4
commit
5ff0e4ed56
@ -1560,8 +1560,9 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
||||
}
|
||||
}
|
||||
if (which) { /* mark remaining ones as failed */
|
||||
log_info(LD_DIR, "Received %d/%d routers requested from %s:%d",
|
||||
log_info(LD_DIR, "Received %d/%d %s requested from %s:%d",
|
||||
n_asked_for-smartlist_len(which), n_asked_for,
|
||||
was_ei ? "extra-info documents" : "router descriptors",
|
||||
conn->_base.address, (int)conn->_base.port);
|
||||
if (smartlist_len(which)) {
|
||||
dir_routerdesc_download_failed(which, status_code,
|
||||
|
@ -780,9 +780,16 @@ update_consensus_networkstatus_fetch_time(time_t now)
|
||||
tor_assert(start+dl_interval < c->valid_until);
|
||||
time_to_download_next_consensus = start + crypto_rand_int(dl_interval);
|
||||
{
|
||||
char tbuf[ISO_TIME_LEN+1];
|
||||
format_local_iso_time(tbuf, time_to_download_next_consensus);
|
||||
log_info(LD_DIR, "Have a live consensus; fetching next one at %s.",tbuf);
|
||||
char tbuf1[ISO_TIME_LEN+1];
|
||||
char tbuf2[ISO_TIME_LEN+1];
|
||||
char tbuf3[ISO_TIME_LEN+1];
|
||||
format_local_iso_time(tbuf1, c->fresh_until);
|
||||
format_local_iso_time(tbuf2, c->valid_until);
|
||||
format_local_iso_time(tbuf3, time_to_download_next_consensus);
|
||||
log_info(LD_DIR, "Live consensus %s the most recent until %s and will "
|
||||
"expire at %s; fetching the next one at %s.",
|
||||
(c->fresh_until > now) ? "will be" : "was",
|
||||
tbuf1, tbuf2, tbuf3);
|
||||
}
|
||||
} else {
|
||||
time_to_download_next_consensus = now;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user