summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-18 11:19:14 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-22 15:55:09 -0400
commit2d7b5c6fe5dc46b7e7cd040e6723e25d12015985 (patch)
treedb395133c56e01ab76582757bbccd28b5a8e0265 /src/or/directory.c
parent9aaed729c188a1f560d025388374c7dc1135478e (diff)
downloadtor-2d7b5c6fe5dc46b7e7cd040e6723e25d12015985.tar.gz
tor-2d7b5c6fe5dc46b7e7cd040e6723e25d12015985.zip
Change the type of "download schedule" from smartlist to int.
This is done as follows: * Only one function (find_dl_schedule()) actually returned a smartlist. Now it returns an int. * The CSV_INTERVAL type has been altered to ignore everything after the first comma, and to store the value before the first comma in an int.
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 3e4d978eed..7b7dc5b355 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -5303,7 +5303,7 @@ connection_dir_finished_connecting(dir_connection_t *conn)
* Then return a list of int pointers defining download delays in seconds.
* Helper function for download_status_increment_failure(),
* download_status_reset(), and download_status_increment_attempt(). */
-STATIC const smartlist_t *
+STATIC int
find_dl_schedule(const download_status_t *dls, const or_options_t *options)
{
switch (dls->schedule) {
@@ -5359,25 +5359,19 @@ find_dl_schedule(const download_status_t *dls, const or_options_t *options)
}
/* Impossible, but gcc will fail with -Werror without a `return`. */
- return NULL;
+ return 0;
}
/** Decide which minimum delay step we want to use based on
* descriptor type in <b>dls</b> and <b>options</b>.
* Helper function for download_status_schedule_get_delay(). */
STATIC int
-find_dl_min_delay(download_status_t *dls, const or_options_t *options)
+find_dl_min_delay(const download_status_t *dls, const or_options_t *options)
{
tor_assert(dls);
tor_assert(options);
- /*
- * For now, just use the existing schedule config stuff and pick the
- * first/last entries off to get min/max delay for backoff purposes
- */
- const smartlist_t *schedule = find_dl_schedule(dls, options);
- tor_assert(schedule != NULL && smartlist_len(schedule) >= 2);
- return *(int *)(smartlist_get(schedule, 0));
+ return find_dl_schedule(dls, options);
}
/** As next_random_exponential_delay() below, but does not compute a random
@@ -5634,10 +5628,9 @@ download_status_increment_attempt(download_status_t *dls, const char *item,
static time_t
download_status_get_initial_delay_from_now(const download_status_t *dls)
{
- const smartlist_t *schedule = find_dl_schedule(dls, get_options());
/* We use constant initial delays, even in exponential backoff
* schedules. */
- return time(NULL) + *(int *)smartlist_get(schedule, 0);
+ return time(NULL) + find_dl_min_delay(dls, get_options());
}
/** Reset <b>dls</b> so that it will be considered downloadable