aboutsummaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2013-10-10 21:39:21 -0400
committerRoger Dingledine <arma@torproject.org>2013-10-10 21:39:21 -0400
commitf96a8d5fa36b785632f54d929b9d70558e634f1a (patch)
tree068b6fb2b0879e50b85365f166ce509cb41b8e05 /src/or/nodelist.c
parent78251e004f03eca93dfbdae2a2b6c18bff948bf2 (diff)
downloadtor-f96a8d5fa36b785632f54d929b9d70558e634f1a.tar
tor-f96a8d5fa36b785632f54d929b9d70558e634f1a.tar.gz
Report bootstrapping progress correctly when downloading microdescs
We had updated our "do we have enough microdescs to begin building circuits?" logic most recently in 0.2.4.10-alpha (see bug 5956), but we left the bootstrap status event logic at "how far through getting 1/4 of them are we?" Fixes bug 9958; bugfix on 0.2.2.36, which is where they diverged (see bug 5343).
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 178f084b6..86219b77c 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -25,6 +25,8 @@
static void nodelist_drop_node(node_t *node, int remove_from_ht);
static void node_free(node_t *node);
static void update_router_have_minimum_dir_info(void);
+static double get_frac_paths_needed_for_circs(const or_options_t *options,
+ const networkstatus_t *ns);
/** A nodelist_t holds a node_t object for every router we're "willing to use
* for something". Specifically, it should hold a node_t for every node that
@@ -1317,7 +1319,7 @@ count_usable_descriptors(int *num_present, int *num_usable,
md ? "microdesc" : "desc", exit_only ? " exits" : "s");
}
-/** Return an extimate of which fraction of usable paths through the Tor
+/** Return an estimate of which fraction of usable paths through the Tor
* network we have available for use. */
static double
compute_frac_paths_available(const networkstatus_t *consensus,
@@ -1372,13 +1374,14 @@ compute_frac_paths_available(const networkstatus_t *consensus,
if (f_myexit < f_exit)
f_exit = f_myexit;
- tor_asprintf(status_out,
- "%d%% of guards bw, "
- "%d%% of midpoint bw, and "
- "%d%% of exit bw",
- (int)(f_guard*100),
- (int)(f_mid*100),
- (int)(f_exit*100));
+ if (status_out)
+ tor_asprintf(status_out,
+ "%d%% of guards bw, "
+ "%d%% of midpoint bw, and "
+ "%d%% of exit bw",
+ (int)(f_guard*100),
+ (int)(f_mid*100),
+ (int)(f_exit*100));
return f_guard * f_mid * f_exit;
}
@@ -1391,19 +1394,19 @@ count_loading_descriptors_progress(void)
{
int num_present = 0, num_usable=0;
time_t now = time(NULL);
+ const or_options_t *options = get_options();
const networkstatus_t *consensus =
networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
- double fraction;
+ double paths, fraction;
if (!consensus)
return 0; /* can't count descriptors if we have no list of them */
- count_usable_descriptors(&num_present, &num_usable, NULL,
- consensus, get_options(), now, NULL, 0);
+ paths = compute_frac_paths_available(consensus, options, now,
+ &num_present, &num_usable,
+ NULL);
- if (num_usable == 0)
- return 0; /* don't div by 0 */
- fraction = num_present / (num_usable/4.);
+ fraction = paths / get_frac_paths_needed_for_circs(options,consensus);
if (fraction > 1.0)
return 0; /* it's not the number of descriptors holding us back */
return BOOTSTRAP_STATUS_LOADING_DESCRIPTORS + (int)