commit d4526e1d4a02b3faa6b7b6030a634cbe20bea9f2 Merge: c13dc51 a574f7f Author: Nick Mathewson nickm@torproject.org Date: Fri Mar 9 13:57:32 2012 -0500
Merge remote-tracking branch 'origin/maint-0.2.2'
Conflicts: src/or/routerlist.c
changes/bug5343 | 7 +++++++ src/or/routerlist.c | 29 ++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-)
diff --cc src/or/routerlist.c index d0ef662,f9d2e85..a9946b8 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@@ -4896,25 -4794,20 +4897,27 @@@ get_dir_info_status_string(void static void count_usable_descriptors(int *num_present, int *num_usable, const networkstatus_t *consensus, - or_options_t *options, time_t now, + const or_options_t *options, time_t now, - routerset_t *in_set) + routerset_t *in_set, int exit_only) { + const int md = (consensus->flavor == FLAV_MICRODESC); *num_present = 0, *num_usable=0;
- SMARTLIST_FOREACH(consensus->routerstatus_list, routerstatus_t *, rs, - { + SMARTLIST_FOREACH_BEGIN(consensus->routerstatus_list, routerstatus_t *, rs) + { + if (exit_only && ! rs->is_exit) + continue; - if (in_set && ! routerset_contains_routerstatus(in_set, rs)) + if (in_set && ! routerset_contains_routerstatus(in_set, rs, -1)) continue; if (client_would_use_router(rs, now, options)) { + const char * const digest = rs->descriptor_digest; + int present; ++*num_usable; /* the consensus says we want it. */ - if (router_get_by_descriptor_digest(rs->descriptor_digest)) { + if (md) + present = NULL != microdesc_cache_lookup_by_digest256(NULL, digest); + else + present = NULL != router_get_by_descriptor_digest(digest); + if (present) { /* we have the descriptor listed in the consensus. */ ++*num_present; } @@@ -4960,12 -4852,12 +4963,13 @@@ static voi update_router_have_minimum_dir_info(void) { int num_present = 0, num_usable=0; + int num_exit_present = 0, num_exit_usable = 0; time_t now = time(NULL); int res; - or_options_t *options = get_options(); + const or_options_t *options = get_options(); const networkstatus_t *consensus = - networkstatus_get_reasonably_live_consensus(now); + networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor()); + int using_md;
if (!consensus) { if (!networkstatus_get_latest_consensus()) @@@ -4986,10 -4878,10 +4990,12 @@@ goto done; }
+ using_md = consensus->flavor == FLAV_MICRODESC; + count_usable_descriptors(&num_present, &num_usable, consensus, options, now, - NULL); + NULL, 0); + count_usable_descriptors(&num_exit_present, &num_exit_usable, + consensus, options, now, options->ExitNodes, 1);
if (num_present < num_usable/4) { tor_snprintf(dir_info_status, sizeof(dir_info_status), @@@ -5000,10 -4891,23 +5006,23 @@@ goto done; } else if (num_present < 2) { tor_snprintf(dir_info_status, sizeof(dir_info_status), - "Only %d descriptor%s here and believed reachable!", - num_present, num_present ? "" : "s"); + "Only %d %sdescriptor%s here and believed reachable!", + num_present, using_md ? "micro" : "", num_present ? "" : "s"); res = 0; goto done; + } else if (num_exit_present < num_exit_usable / 3) { + tor_snprintf(dir_info_status, sizeof(dir_info_status), + "We have only %d/%d usable exit node descriptors.", + num_exit_present, num_exit_usable); + res = 0; + control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_DESCRIPTORS, 0); + goto done; + } else if (num_exit_present < 2) { + tor_snprintf(dir_info_status, sizeof(dir_info_status), + "Only %d descriptor%s here and believed reachable!", + num_exit_present, num_exit_present ? "" : "s"); + res = 0; + goto done; }
/* Check for entry nodes. */
tor-commits@lists.torproject.org