Tor 0.4.9.0-alpha-dev
Macros | Functions
dlstatus.h File Reference

Header file for dlstatus.c. More...

Go to the source code of this file.

Macros

#define download_status_failed(dls, sc)
 

Functions

time_t download_status_increment_failure (download_status_t *dls, int status_code, const char *item, int server, time_t now)
 
time_t download_status_increment_attempt (download_status_t *dls, const char *item, time_t now)
 
void download_status_reset (download_status_t *dls)
 
int download_status_is_ready (download_status_t *dls, time_t now)
 
time_t download_status_get_next_attempt_at (const download_status_t *dls)
 
void download_status_mark_impossible (download_status_t *dl)
 
int download_status_get_n_failures (const download_status_t *dls)
 
int download_status_get_n_attempts (const download_status_t *dls)
 

Detailed Description

Header file for dlstatus.c.

Definition in file dlstatus.h.

Macro Definition Documentation

◆ download_status_failed

#define download_status_failed (   dls,
  sc 
)
Value:
download_status_increment_failure((dls), (sc), NULL, \
time(NULL))
const or_options_t * get_options(void)
Definition: config.c:944
time_t download_status_increment_failure(download_status_t *dls, int status_code, const char *item, int server, time_t now)
Definition: dlstatus.c:249
int dir_server_mode(const or_options_t *options)
Definition: routermode.c:23

Increment the failure count of the download_status_t dls, with the optional status code sc.

Definition at line 22 of file dlstatus.h.

Function Documentation

◆ download_status_get_n_attempts()

int download_status_get_n_attempts ( const download_status_t dls)

Return the number of attempts to download dls since the last success (if any). This can differ from download_status_get_n_failures() due to outstanding concurrent attempts.

Definition at line 410 of file dlstatus.c.

◆ download_status_get_n_failures()

int download_status_get_n_failures ( const download_status_t dls)

Return the number of failures on dls since the last success (if any).

Definition at line 401 of file dlstatus.c.

Referenced by authority_cert_dl_looks_uncertain().

◆ download_status_get_next_attempt_at()

time_t download_status_get_next_attempt_at ( const download_status_t dls)

Return the next time to attempt to download dls.

Definition at line 417 of file dlstatus.c.

Referenced by download_status_is_ready().

◆ download_status_increment_attempt()

time_t download_status_increment_attempt ( download_status_t dls,
const char *  item,
time_t  now 
)

Determine when the next download attempt should be made when using an attempt-based (potentially concurrent) download schedule. Called when an attempt to download dls is being initiated. Increment the attempt count and set dls->next_attempt_at to an appropriate time in the future and return it. If dls->increment_on is DL_SCHED_INCREMENT_FAILURE, don't increment the attempts, and return a time in the far future (to avoid launching a concurrent attempt).

Definition at line 308 of file dlstatus.c.

◆ download_status_increment_failure()

time_t download_status_increment_failure ( download_status_t dls,
int  status_code,
const char *  item,
int  server,
time_t  now 
)

Determine when a failed download attempt should be retried. Called when an attempt to download dls has failed with HTTP status status_code. Increment the failure count (if the code indicates a real failure, or if we're a server) and set dls->next_attempt_at to an appropriate time in the future and return it. If dls->increment_on is DL_SCHED_INCREMENT_ATTEMPT, increment the failure count, and return a time in the far future for the next attempt (to avoid an immediate retry).

Definition at line 249 of file dlstatus.c.

◆ download_status_is_ready()

int download_status_is_ready ( download_status_t dls,
time_t  now 
)

Return true iff, as of now, the resource tracked by dls is ready to get its download reattempted.

Definition at line 380 of file dlstatus.c.

Referenced by download_status_is_ready_by_sk_in_cl(), and fetch_bridge_descriptors().

◆ download_status_mark_impossible()

void download_status_mark_impossible ( download_status_t dl)

Mark dl as never downloadable.

Definition at line 392 of file dlstatus.c.

Referenced by fetch_bridge_descriptors(), and launch_direct_bridge_descriptor_fetch().

◆ download_status_reset()

void download_status_reset ( download_status_t dls)

Reset dls so that it will be considered downloadable immediately, and/or to show that we don't need it anymore.

Must be called to initialise a download schedule, otherwise the zeroth item in the schedule will never be used.

(We find the zeroth element of the download schedule, and set next_attempt_at to be the appropriate offset from 'now'. In most cases this means setting it to 'now', so the item will be immediately downloadable; when using authorities with fallbacks, there is a few seconds' delay.)

Definition at line 363 of file dlstatus.c.

Referenced by download_status_increment_attempt(), download_status_increment_failure(), download_status_is_ready(), and learned_bridge_descriptor().