11#define DLSTATUS_PRIVATE
38 case DL_SCHED_GENERIC:
46 case DL_SCHED_CONSENSUS:
57 ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay;
109 const int delay_times_3 = delay < INT_MAX/3 ? delay * 3 : INT_MAX;
110 *low_bound_out = base_delay;
111 if (delay_times_3 > base_delay) {
112 *high_bound_out = delay_times_3;
114 *high_bound_out = base_delay+1;
139 int low_bound=0, high_bound=INT_MAX;
163 == DL_SCHED_INCREMENT_ATTEMPT
173 if (dls_schedule_position > 0) {
188 if (min_delay >= 0 && delay < min_delay) delay = min_delay;
200 if (delay < INT_MAX && now <= TIME_MAX - delay) {
216download_status_log_helper(
const char *item,
int was_schedule_incremented,
217 const char *increment_action,
218 const char *not_incremented_response,
219 uint8_t dls_n_download_increments,
int increment,
220 time_t dls_next_attempt_at, time_t now)
223 if (!was_schedule_incremented)
224 log_debug(
LD_DIR,
"%s %s %d time(s); I'll try again %s.",
225 item, increment_action, (
int)dls_n_download_increments,
226 not_incremented_response);
227 else if (increment == 0)
228 log_debug(
LD_DIR,
"%s %s %d time(s); I'll try again immediately.",
229 item, increment_action, (
int)dls_n_download_increments);
230 else if (dls_next_attempt_at < TIME_MAX)
231 log_debug(
LD_DIR,
"%s %s %d time(s); I'll try again in %d seconds.",
232 item, increment_action, (
int)dls_n_download_increments,
233 (
int)(dls_next_attempt_at-now));
235 log_debug(
LD_DIR,
"%s %s %d time(s); Giving up for a while.",
236 item, increment_action, (
int)dls_n_download_increments);
250 const char *item,
int server, time_t now)
284 download_status_log_helper(item, !dls->
increment_on,
"failed",
324 log_warn(
LD_BUG,
"Tried to launch an attempt-based connection on a "
325 "failure-based schedule.");
335 download_status_log_helper(item, dls->
increment_on,
"attempted",
371 dls->
next_attempt_at = download_status_get_initial_delay_from_now(dls);
422 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.
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
#define IF_BUG_ONCE(cond)