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 */
9 * \brief Header file for dlstatus.c.
12 #ifndef TOR_DLSTATUS_H
13 #define TOR_DLSTATUS_H
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()), \
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
);
32 int download_status_get_n_failures(const download_status_t
*dls
);
33 int download_status_get_n_attempts(const download_status_t
*dls
);
35 #ifdef DLSTATUS_PRIVATE
36 STATIC
int download_status_schedule_get_delay(download_status_t
*dls
,
40 STATIC
int find_dl_min_delay(const download_status_t
*dls
,
41 const or_options_t
*options
);
43 STATIC
int next_random_exponential_delay(int delay
,
46 STATIC
void next_random_exponential_delay_range(int *low_bound_out
,
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)
56 #endif /* defined(DLSTATUS_PRIVATE) */
58 #endif /* !defined(TOR_DLSTATUS_H) */