diff options
author | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2015-12-07 17:55:38 +1100 |
---|---|---|
committer | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2015-12-16 04:37:49 +1100 |
commit | 35bbf2e4a4e8ccbc4126ebffda67c48989ec2f06 (patch) | |
tree | fd5350e11f9c31c0e59b3eb9c0f8189daf1eea94 /src/or/main.c | |
parent | d3546aa92bf5c7c1435381b33a42f2a4a3d3c2f5 (diff) | |
download | tor-35bbf2e4a4e8ccbc4126ebffda67c48989ec2f06.tar.gz tor-35bbf2e4a4e8ccbc4126ebffda67c48989ec2f06.zip |
Prop210: Add schedules for simultaneous client consensus downloads
Prop210: Add attempt-based connection schedules
Existing tor schedules increment the schedule position on failure,
then retry the connection after the scheduled time.
To make multiple simultaneous connections, we need to increment the
schedule position when making each attempt, then retry a (potentially
simultaneous) connection after the scheduled time.
(Also change find_dl_schedule_and_len to find_dl_schedule, as it no
longer takes or returns len.)
Prop210: Add multiple simultaneous consensus downloads for clients
Make connections on TestingClientBootstrapConsensus*DownloadSchedule,
incrementing the schedule each time the client attempts to connect.
Check if the number of downloads is less than
TestingClientBootstrapConsensusMaxInProgressTries before trying any
more connections.
Diffstat (limited to 'src/or/main.c')
-rw-r--r-- | src/or/main.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/or/main.c b/src/or/main.c index 527e2b1ffe..60957bd6ab 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1876,18 +1876,29 @@ check_for_reachability_bw_callback(time_t now, const or_options_t *options) static int fetch_networkstatus_callback(time_t now, const or_options_t *options) { - /* 2c. Every minute (or every second if TestingTorNetwork), check - * whether we want to download any networkstatus documents. */ + /* 2c. Every minute (or every second if TestingTorNetwork, or during + * client bootstrap), check whether we want to download any networkstatus + * documents. */ /* How often do we check whether we should download network status * documents? */ -#define networkstatus_dl_check_interval(o) ((o)->TestingTorNetwork ? 1 : 60) + const int we_are_bootstrapping = networkstatus_consensus_is_boostrapping( + now); + const int prefer_mirrors = !directory_fetches_from_authorities( + get_options()); + int networkstatus_dl_check_interval = 60; + /* check more often when testing, or when bootstrapping from mirrors + * (connection limits prevent too many connections being made) */ + if (options->TestingTorNetwork + || (we_are_bootstrapping && prefer_mirrors)) { + networkstatus_dl_check_interval = 1; + } if (should_delay_dir_fetches(options, NULL)) return PERIODIC_EVENT_NO_UPDATE; update_networkstatus_downloads(now); - return networkstatus_dl_check_interval(options); + return networkstatus_dl_check_interval; } static int |