11 #define DLSTATUS_PRIVATE
38 case DL_SCHED_GENERIC:
46 case DL_SCHED_CONSENSUS:
57 ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay;
110 const int delay_times_3 = delay < INT_MAX/3 ? delay * 3 : INT_MAX;
111 *low_bound_out = base_delay;
112 if (delay_times_3 > base_delay) {
113 *high_bound_out = delay_times_3;
115 *high_bound_out = base_delay+1;
140 int low_bound=0, high_bound=INT_MAX;
164 == DL_SCHED_INCREMENT_ATTEMPT
174 if (dls_schedule_position > 0) {
189 if (min_delay >= 0 && delay < min_delay) delay = min_delay;
201 if (delay < INT_MAX && now <= TIME_MAX - delay) {
217 download_status_log_helper(
const char *item,
int was_schedule_incremented,
218 const char *increment_action,
219 const char *not_incremented_response,
220 uint8_t dls_n_download_increments,
int increment,
221 time_t dls_next_attempt_at, time_t now)
224 if (!was_schedule_incremented)
225 log_debug(
LD_DIR,
"%s %s %d time(s); I'll try again %s.",
226 item, increment_action, (
int)dls_n_download_increments,
227 not_incremented_response);
228 else if (increment == 0)
229 log_debug(
LD_DIR,
"%s %s %d time(s); I'll try again immediately.",
230 item, increment_action, (
int)dls_n_download_increments);
231 else if (dls_next_attempt_at < TIME_MAX)
232 log_debug(
LD_DIR,
"%s %s %d time(s); I'll try again in %d seconds.",
233 item, increment_action, (
int)dls_n_download_increments,
234 (
int)(dls_next_attempt_at-now));
236 log_debug(
LD_DIR,
"%s %s %d time(s); Giving up for a while.",
237 item, increment_action, (
int)dls_n_download_increments);
251 const char *item,
int server, time_t now)
285 download_status_log_helper(item, !dls->
increment_on,
"failed",
325 log_warn(
LD_BUG,
"Tried to launch an attempt-based connection on a "
326 "failure-based schedule.");
336 download_status_log_helper(item, dls->
increment_on,
"attempted",
372 dls->
next_attempt_at = download_status_get_initial_delay_from_now(dls);
423 return download_status_get_initial_delay_from_now(dls);
const or_options_t * get_options(void)
Header file for config.c.
Common functions for using (pseudo-)random number generators.
int crypto_rand_int_range(unsigned int min, unsigned int max)
STATIC void next_random_exponential_delay_range(int *low_bound_out, int *high_bound_out, int delay, int base_delay)
STATIC int download_status_schedule_get_delay(download_status_t *dls, int min_delay, time_t now)
int download_status_get_n_attempts(const download_status_t *dls)
int download_status_is_ready(download_status_t *dls, time_t now)
STATIC int find_dl_min_delay(const download_status_t *dls, const or_options_t *options)
int download_status_get_n_failures(const download_status_t *dls)
time_t download_status_increment_attempt(download_status_t *dls, const char *item, time_t now)
time_t download_status_get_next_attempt_at(const download_status_t *dls)
time_t download_status_increment_failure(download_status_t *dls, int status_code, const char *item, int server, time_t now)
void download_status_mark_impossible(download_status_t *dl)
void download_status_reset(download_status_t *dls)
STATIC int next_random_exponential_delay(int delay, int base_delay)
Header file for dlstatus.c.
Directory download status/schedule structure.
int num_bridges_usable(int use_maybe_reachable)
Header file for circuitbuild.c.
int networkstatus_consensus_can_use_multiple_directories(const or_options_t *options)
int networkstatus_consensus_is_bootstrapping(time_t now)
int networkstatus_consensus_can_use_extra_fallbacks(const or_options_t *options)
Header file for networkstatus.c.
Master header file for Tor-specific functionality.
#define IMPOSSIBLE_TO_DOWNLOAD
int dir_server_mode(const or_options_t *options)
Header file for routermode.c.
download_want_authority_bitfield_t want_authority
download_schedule_increment_bitfield_t increment_on
uint8_t last_backoff_position
uint8_t n_download_attempts
uint8_t n_download_failures
download_schedule_bitfield_t schedule
int TestingClientDownloadInitialDelay
int ClientBootstrapConsensusFallbackDownloadInitialDelay
int TestingBridgeBootstrapDownloadInitialDelay
int ClientBootstrapConsensusAuthorityDownloadInitialDelay
int TestingClientConsensusDownloadInitialDelay
int TestingServerConsensusDownloadInitialDelay
int TestingServerDownloadInitialDelay
int TestingBridgeDownloadInitialDelay
#define IF_BUG_ONCE(cond)