mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
report partial bootstrapping progress as we fetch descriptors
svn:r15083
This commit is contained in:
parent
eafb07ec96
commit
6aeb79af06
@ -1304,6 +1304,8 @@ load_downloaded_routers(const char *body, smartlist_t *which,
|
||||
|
||||
router_load_routers_from_string(body, NULL, SAVED_NOWHERE, which,
|
||||
descriptor_digests, buf);
|
||||
control_event_bootstrap(BOOTSTRAP_STATUS_LOADING_DESCRIPTORS,
|
||||
count_loading_descriptors_progress());
|
||||
}
|
||||
|
||||
/** We are a client, and we've finished reading the server's
|
||||
|
@ -4047,6 +4047,7 @@ void update_extrainfo_downloads(time_t now);
|
||||
int router_have_minimum_dir_info(void);
|
||||
void router_dir_info_changed(void);
|
||||
const char *get_dir_info_status_string(void);
|
||||
int count_loading_descriptors_progress(void);
|
||||
void router_reset_descriptor_download_failures(void);
|
||||
int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
|
||||
int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
|
||||
|
@ -949,7 +949,8 @@ connection_edge_process_relay_cell_not_open(
|
||||
control_event_bootstrap(BOOTSTRAP_STATUS_LOADING_STATUS, 0);
|
||||
break;
|
||||
case DIR_PURPOSE_FETCH_SERVERDESC:
|
||||
control_event_bootstrap(BOOTSTRAP_STATUS_LOADING_DESCRIPTORS, 0);
|
||||
control_event_bootstrap(BOOTSTRAP_STATUS_LOADING_DESCRIPTORS,
|
||||
count_loading_descriptors_progress());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -4168,6 +4168,52 @@ get_dir_info_status_string(void)
|
||||
return dir_info_status;
|
||||
}
|
||||
|
||||
static void
|
||||
count_usable_descriptors(int *num_present, int *num_usable,
|
||||
const networkstatus_t *consensus,
|
||||
or_options_t *options, time_t now)
|
||||
{
|
||||
*num_present = 0, *num_usable=0;
|
||||
|
||||
SMARTLIST_FOREACH(consensus->routerstatus_list, routerstatus_t *, rs,
|
||||
{
|
||||
if (client_would_use_router(rs, now, options)) {
|
||||
++*num_usable; /* the consensus says we want it. */
|
||||
if (router_get_by_descriptor_digest(rs->descriptor_digest)) {
|
||||
/* we have the descriptor listed in the consensus. */
|
||||
++*num_present;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
log_debug(LD_DIR, "%d usable, %d present.", *num_usable, *num_present);
|
||||
}
|
||||
|
||||
int
|
||||
count_loading_descriptors_progress(void)
|
||||
{
|
||||
int num_present = 0, num_usable=0;
|
||||
time_t now = time(NULL);
|
||||
const networkstatus_t *consensus =
|
||||
networkstatus_get_reasonably_live_consensus(now);
|
||||
double fraction;
|
||||
|
||||
if (!consensus)
|
||||
return 0; /* can't count descriptors if we have no list of them */
|
||||
|
||||
count_usable_descriptors(&num_present, &num_usable,
|
||||
consensus, get_options(), now);
|
||||
|
||||
if (num_usable == 0)
|
||||
return 0; /* don't div by 0 */
|
||||
fraction = num_present / (num_usable/4.);
|
||||
if (fraction > 1.0)
|
||||
return 0; /* it's not the number of descriptors holding us back */
|
||||
return BOOTSTRAP_STATUS_LOADING_DESCRIPTORS +
|
||||
fraction*(BOOTSTRAP_STATUS_CONN_OR-1 -
|
||||
BOOTSTRAP_STATUS_LOADING_DESCRIPTORS);
|
||||
}
|
||||
|
||||
/** Change the value of have_min_dir_info, setting it true iff we have enough
|
||||
* network and router information to build circuits. Clear the value of
|
||||
* need_to_update_have_min_dir_info. */
|
||||
@ -4200,18 +4246,7 @@ update_router_have_minimum_dir_info(void)
|
||||
goto done;
|
||||
}
|
||||
|
||||
SMARTLIST_FOREACH(consensus->routerstatus_list, routerstatus_t *, rs,
|
||||
{
|
||||
if (client_would_use_router(rs, now, options)) {
|
||||
++num_usable; /* the consensus says we want it. */
|
||||
if (router_get_by_descriptor_digest(rs->descriptor_digest)) {
|
||||
/* we have the descriptor listed in the consensus. */
|
||||
++num_present;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
log_debug(LD_DIR, "%d usable, %d present.", num_usable, num_present);
|
||||
count_usable_descriptors(&num_present, &num_usable, consensus, options, now);
|
||||
|
||||
if (num_present < num_usable/4) {
|
||||
tor_snprintf(dir_info_status, sizeof(dir_info_status),
|
||||
|
Loading…
Reference in New Issue
Block a user