summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-05-18 18:07:40 -0400
committerNick Mathewson <nickm@torproject.org>2016-05-19 07:58:40 -0400
commitab0a7e2961378ff0fb7f5061d6b1cdeebe7afa98 (patch)
treea8880c899a4d9db76582198d8e512d3d2322113e /src
parent8dc8d712260a16eb9811b57abd4928081316f495 (diff)
downloadtor-ab0a7e2961378ff0fb7f5061d6b1cdeebe7afa98.tar.gz
tor-ab0a7e2961378ff0fb7f5061d6b1cdeebe7afa98.zip
Remove consensus_max_download_tries by refactoring
No behaviour change This function is used twice. The code is simpler if we split it up and inline it where it is used.
Diffstat (limited to 'src')
-rw-r--r--src/or/networkstatus.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 5e32003afb..5c9283004e 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -791,26 +791,6 @@ check_consensus_waiting_for_certs(int flavor, time_t now,
return 0;
}
-/* Return the maximum download tries for a consensus, based on options and
- * whether we_are_bootstrapping. */
-static int
-consensus_max_download_tries(const or_options_t *options,
- int we_are_bootstrapping)
-{
- int use_fallbacks = networkstatus_consensus_can_use_extra_fallbacks(options);
-
- if (we_are_bootstrapping) {
- if (use_fallbacks) {
- return options->ClientBootstrapConsensusMaxDownloadTries;
- } else {
- return
- options->ClientBootstrapConsensusAuthorityOnlyMaxDownloadTries;
- }
- }
-
- return options->TestingConsensusMaxDownloadTries;
-}
-
/** If we want to download a fresh consensus, launch a new download as
* appropriate. */
static void
@@ -871,7 +851,7 @@ update_consensus_networkstatus_downloads(time_t now)
update_consensus_bootstrap_multiple_downloads(now, options);
} else {
/* Check if we failed downloading a consensus too recently */
- int max_dl_tries = consensus_max_download_tries(options, 0);
+ int max_dl_tries = options->TestingConsensusMaxDownloadTries;
/* Let's make sure we remembered to update consensus_dl_status */
tor_assert(consensus_dl_status[i].schedule == DL_SCHED_CONSENSUS);
@@ -909,7 +889,13 @@ update_consensus_bootstrap_attempt_downloads(
download_status_t *dls,
download_want_authority_t want_authority)
{
- int max_dl_tries = consensus_max_download_tries(options, 1);
+ int use_fallbacks = networkstatus_consensus_can_use_extra_fallbacks(options);
+ int max_dl_tries = options->ClientBootstrapConsensusMaxDownloadTries;
+ if (!use_fallbacks) {
+ max_dl_tries =
+ options->ClientBootstrapConsensusAuthorityOnlyMaxDownloadTries;
+ }
+
const char *resource = networkstatus_get_flavor_name(
usable_consensus_flavor());