dlstatus.h (2454B)
1 /* Copyright (c) 2001 Matej Pfajfar. 2 * Copyright (c) 2001-2004, Roger Dingledine. 3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 4 * Copyright (c) 2007-2021, The Tor Project, Inc. */ 5 /* See LICENSE for licensing information */ 6 7 /** 8 * \file dlstatus.h 9 * \brief Header file for dlstatus.c. 10 **/ 11 12 #ifndef TOR_DLSTATUS_H 13 #define TOR_DLSTATUS_H 14 15 time_t download_status_increment_failure(download_status_t *dls, 16 int status_code, const char *item, 17 int server, time_t now); 18 time_t download_status_increment_attempt(download_status_t *dls, 19 const char *item, time_t now); 20 /** Increment the failure count of the download_status_t <b>dls</b>, with 21 * the optional status code <b>sc</b>. */ 22 #define download_status_failed(dls, sc) \ 23 download_status_increment_failure((dls), (sc), NULL, \ 24 dir_server_mode(get_options()), \ 25 time(NULL)) 26 27 void download_status_reset(download_status_t *dls); 28 int download_status_is_ready(download_status_t *dls, time_t now); 29 time_t download_status_get_next_attempt_at(const download_status_t *dls); 30 void download_status_mark_impossible(download_status_t *dl); 31 32 int download_status_get_n_failures(const download_status_t *dls); 33 int download_status_get_n_attempts(const download_status_t *dls); 34 35 #ifdef DLSTATUS_PRIVATE 36 STATIC int download_status_schedule_get_delay(download_status_t *dls, 37 int min_delay, 38 time_t now); 39 40 STATIC int find_dl_min_delay(const download_status_t *dls, 41 const or_options_t *options); 42 43 STATIC int next_random_exponential_delay(int delay, 44 int base_delay); 45 46 STATIC void next_random_exponential_delay_range(int *low_bound_out, 47 int *high_bound_out, 48 int delay, 49 int base_delay); 50 51 /* no more than quadruple the previous delay (multiplier + 1) */ 52 #define DIR_DEFAULT_RANDOM_MULTIPLIER (3) 53 /* no more than triple the previous delay */ 54 #define DIR_TEST_NET_RANDOM_MULTIPLIER (2) 55 56 #endif /* defined(DLSTATUS_PRIVATE) */ 57 58 #endif /* !defined(TOR_DLSTATUS_H) */