Tor 0.4.9.3-alpha-dev
Loading...
Searching...
No Matches
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, \
dir_server_mode(get_options()), \
time(NULL))
const or_options_t * get_options(void)
Definition config.c:948
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

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_increment_attempt(), download_status_increment_failure(), download_status_is_ready(), and download_status_to_string().

◆ 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.

Referenced by fetch_bridge_descriptors(), and update_consensus_bootstrap_attempt_downloads().

◆ 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.

Referenced by dir_microdesc_download_failed(), and dir_routerdesc_download_failed().

◆ download_status_is_ready()

int download_status_is_ready ( download_status_t dls,
time_t  now 
)

◆ download_status_mark_impossible()

void download_status_mark_impossible ( download_status_t dl)

◆ 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 authority_certs_fetch_missing(), download_status_cert_init(), download_status_increment_attempt(), download_status_increment_failure(), download_status_is_ready(), download_status_reset_by_sk_in_cl(), learned_bridge_descriptor(), networkstatus_reset_download_failures(), networkstatus_set_current_consensus(), and routers_update_status_from_consensus_networkstatus().