diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-15 14:58:43 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-15 14:58:43 -0400 |
commit | f85d731e3af16e72682f68be4f598f08ed227618 (patch) | |
tree | 727452686f998e183a88ce70254ddb97caaed44e /src/or/directory.c | |
parent | 03fc83ab6da6b73b930e422c57089ad5a4907c83 (diff) | |
download | tor-f85d731e3af16e72682f68be4f598f08ed227618.tar.gz tor-f85d731e3af16e72682f68be4f598f08ed227618.zip |
Extract download_status_t into its own header.
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 4e2e968867..f6d6d28d4a 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -5632,6 +5632,27 @@ download_status_reset(download_status_t *dls) /* Don't reset dls->want_authority or dls->increment_on */ } +/** Return true iff, as of <b>now</b>, the resource tracked by <b>dls</b> is + * ready to get its download reattempted. */ +int +download_status_is_ready(download_status_t *dls, time_t now) +{ + /* dls wasn't reset before it was used */ + if (dls->next_attempt_at == 0) { + download_status_reset(dls); + } + + return download_status_get_next_attempt_at(dls) <= now; +} + +/** Mark <b>dl</b> as never downloadable. */ +void +download_status_mark_impossible(download_status_t *dl) +{ + dl->n_download_failures = IMPOSSIBLE_TO_DOWNLOAD; + dl->n_download_attempts = IMPOSSIBLE_TO_DOWNLOAD; +} + /** Return the number of failures on <b>dls</b> since the last success (if * any). */ int |