[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Rename find_dl_schedule to find_dl_min_delay.
commit ff6f49f033a6fdcc63eb790548b22b9cb23d3d33
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Apr 18 11:26:40 2018 -0400
Rename find_dl_schedule to find_dl_min_delay.
(We no longer need two separate functions here.)
---
src/or/directory.c | 21 +++++++--------------
src/or/directory.h | 2 --
src/test/test_dir.c | 44 ++++++++++++++++++++++----------------------
3 files changed, 29 insertions(+), 38 deletions(-)
diff --git a/src/or/directory.c b/src/or/directory.c
index 7b7dc5b35..0cbf342df 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -5300,12 +5300,17 @@ connection_dir_finished_connecting(dir_connection_t *conn)
/** Decide which download schedule we want to use based on descriptor type
* in <b>dls</b> and <b>options</b>.
- * Then return a list of int pointers defining download delays in seconds.
+ *
+ * Then, return the initial delay for that download schedule, in seconds.
+ *
* Helper function for download_status_increment_failure(),
* download_status_reset(), and download_status_increment_attempt(). */
STATIC int
-find_dl_schedule(const 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);
+
switch (dls->schedule) {
case DL_SCHED_GENERIC:
/* Any other directory document */
@@ -5362,18 +5367,6 @@ find_dl_schedule(const download_status_t *dls, const or_options_t *options)
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(const download_status_t *dls, const or_options_t *options)
-{
- tor_assert(dls);
- tor_assert(options);
-
- return find_dl_schedule(dls, options);
-}
-
/** As next_random_exponential_delay() below, but does not compute a random
* value. Instead, compute the range of values that
* next_random_exponential_delay() should use when computing its random value.
diff --git a/src/or/directory.h b/src/or/directory.h
index e082bbf7b..5f5ff7eca 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -259,8 +259,6 @@ STATIC char* authdir_type_to_string(dirinfo_type_t auth);
STATIC const char * dir_conn_purpose_to_string(int purpose);
STATIC int should_use_directory_guards(const or_options_t *options);
STATIC compression_level_t choose_compression_level(ssize_t n_bytes);
-STATIC int find_dl_schedule(const download_status_t *dls,
- const or_options_t *options);
STATIC int find_dl_min_delay(const download_status_t *dls,
const or_options_t *options);
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 8926221f0..367ecf0b9 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -5432,7 +5432,7 @@ mock_num_bridges_usable(int use_maybe_reachable)
* fallbacks.
*/
static void
-test_dir_find_dl_schedule(void* data)
+test_dir_find_dl_min_delay(void* data)
{
const char *str = (const char *)data;
@@ -5490,20 +5490,20 @@ test_dir_find_dl_schedule(void* data)
dls.schedule = DL_SCHED_GENERIC;
/* client */
mock_options->ClientOnly = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ, client);
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, client);
mock_options->ClientOnly = 0;
/* dir mode */
mock_options->DirPort_set = 1;
mock_options->DirCache = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ, server);
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, server);
mock_options->DirPort_set = 0;
mock_options->DirCache = 0;
dls.schedule = DL_SCHED_CONSENSUS;
/* public server mode */
mock_options->ORPort_set = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ, server_cons);
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, server_cons);
mock_options->ORPort_set = 0;
/* client and bridge modes */
@@ -5512,14 +5512,14 @@ test_dir_find_dl_schedule(void* data)
dls.want_authority = 1;
/* client */
mock_options->ClientOnly = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_boot_auth_cons);
mock_options->ClientOnly = 0;
/* bridge relay */
mock_options->ORPort_set = 1;
mock_options->BridgeRelay = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_boot_auth_cons);
mock_options->ORPort_set = 0;
mock_options->BridgeRelay = 0;
@@ -5527,14 +5527,14 @@ test_dir_find_dl_schedule(void* data)
dls.want_authority = 0;
/* client */
mock_options->ClientOnly = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_boot_fallback_cons);
mock_options->ClientOnly = 0;
/* bridge relay */
mock_options->ORPort_set = 1;
mock_options->BridgeRelay = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_boot_fallback_cons);
mock_options->ORPort_set = 0;
mock_options->BridgeRelay = 0;
@@ -5543,14 +5543,14 @@ test_dir_find_dl_schedule(void* data)
/* dls.want_authority is ignored */
/* client */
mock_options->ClientOnly = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_boot_auth_only_cons);
mock_options->ClientOnly = 0;
/* bridge relay */
mock_options->ORPort_set = 1;
mock_options->BridgeRelay = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_boot_auth_only_cons);
mock_options->ORPort_set = 0;
mock_options->BridgeRelay = 0;
@@ -5558,14 +5558,14 @@ test_dir_find_dl_schedule(void* data)
} else {
/* client */
mock_options->ClientOnly = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_cons);
mock_options->ClientOnly = 0;
/* bridge relay */
mock_options->ORPort_set = 1;
mock_options->BridgeRelay = 1;
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ,
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
client_cons);
mock_options->ORPort_set = 0;
mock_options->BridgeRelay = 0;
@@ -5576,9 +5576,9 @@ test_dir_find_dl_schedule(void* data)
mock_options->ClientOnly = 1;
mock_options->UseBridges = 1;
if (num_bridges_usable(0) > 0) {
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ, bridge);
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, bridge);
} else {
- tt_int_op(find_dl_schedule(&dls, mock_options), OP_EQ, bridge_bootstrap);
+ tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, bridge_bootstrap);
}
done:
@@ -5872,14 +5872,14 @@ struct testcase_t dir_tests[] = {
DIR(dump_unparseable_descriptors, 0),
DIR(populate_dump_desc_fifo, 0),
DIR(populate_dump_desc_fifo_2, 0),
- DIR_ARG(find_dl_schedule, TT_FORK, "bfd"),
- DIR_ARG(find_dl_schedule, TT_FORK, "bad"),
- DIR_ARG(find_dl_schedule, TT_FORK, "cfd"),
- DIR_ARG(find_dl_schedule, TT_FORK, "cad"),
- DIR_ARG(find_dl_schedule, TT_FORK, "bfr"),
- DIR_ARG(find_dl_schedule, TT_FORK, "bar"),
- DIR_ARG(find_dl_schedule, TT_FORK, "cfr"),
- DIR_ARG(find_dl_schedule, TT_FORK, "car"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "bfd"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "bad"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "cfd"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "cad"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "bfr"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "bar"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "cfr"),
+ DIR_ARG(find_dl_min_delay, TT_FORK, "car"),
DIR(assumed_flags, 0),
DIR(networkstatus_compute_bw_weights_v10, 0),
DIR(platform_str, 0),
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits