mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Rename find_dl_schedule to find_dl_min_delay.
(We no longer need two separate functions here.)
This commit is contained in:
parent
82d1d8b071
commit
ff6f49f033
@ -5300,12 +5300,17 @@ connection_dir_finished_connecting(dir_connection_t *conn)
|
|||||||
|
|
||||||
/** Decide which download schedule we want to use based on descriptor type
|
/** Decide which download schedule we want to use based on descriptor type
|
||||||
* in <b>dls</b> and <b>options</b>.
|
* 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(),
|
* Helper function for download_status_increment_failure(),
|
||||||
* download_status_reset(), and download_status_increment_attempt(). */
|
* download_status_reset(), and download_status_increment_attempt(). */
|
||||||
STATIC int
|
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) {
|
switch (dls->schedule) {
|
||||||
case DL_SCHED_GENERIC:
|
case DL_SCHED_GENERIC:
|
||||||
/* Any other directory document */
|
/* Any other directory document */
|
||||||
@ -5362,18 +5367,6 @@ find_dl_schedule(const download_status_t *dls, const or_options_t *options)
|
|||||||
return 0;
|
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
|
/** As next_random_exponential_delay() below, but does not compute a random
|
||||||
* value. Instead, compute the range of values that
|
* value. Instead, compute the range of values that
|
||||||
* next_random_exponential_delay() should use when computing its random value.
|
* next_random_exponential_delay() should use when computing its random value.
|
||||||
|
@ -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 const char * dir_conn_purpose_to_string(int purpose);
|
||||||
STATIC int should_use_directory_guards(const or_options_t *options);
|
STATIC int should_use_directory_guards(const or_options_t *options);
|
||||||
STATIC compression_level_t choose_compression_level(ssize_t n_bytes);
|
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,
|
STATIC int find_dl_min_delay(const download_status_t *dls,
|
||||||
const or_options_t *options);
|
const or_options_t *options);
|
||||||
|
|
||||||
|
@ -5432,7 +5432,7 @@ mock_num_bridges_usable(int use_maybe_reachable)
|
|||||||
* fallbacks.
|
* fallbacks.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
test_dir_find_dl_schedule(void* data)
|
test_dir_find_dl_min_delay(void* data)
|
||||||
{
|
{
|
||||||
const char *str = (const char *)data;
|
const char *str = (const char *)data;
|
||||||
|
|
||||||
@ -5490,20 +5490,20 @@ test_dir_find_dl_schedule(void* data)
|
|||||||
dls.schedule = DL_SCHED_GENERIC;
|
dls.schedule = DL_SCHED_GENERIC;
|
||||||
/* client */
|
/* client */
|
||||||
mock_options->ClientOnly = 1;
|
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;
|
mock_options->ClientOnly = 0;
|
||||||
|
|
||||||
/* dir mode */
|
/* dir mode */
|
||||||
mock_options->DirPort_set = 1;
|
mock_options->DirPort_set = 1;
|
||||||
mock_options->DirCache = 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->DirPort_set = 0;
|
||||||
mock_options->DirCache = 0;
|
mock_options->DirCache = 0;
|
||||||
|
|
||||||
dls.schedule = DL_SCHED_CONSENSUS;
|
dls.schedule = DL_SCHED_CONSENSUS;
|
||||||
/* public server mode */
|
/* public server mode */
|
||||||
mock_options->ORPort_set = 1;
|
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;
|
mock_options->ORPort_set = 0;
|
||||||
|
|
||||||
/* client and bridge modes */
|
/* client and bridge modes */
|
||||||
@ -5512,14 +5512,14 @@ test_dir_find_dl_schedule(void* data)
|
|||||||
dls.want_authority = 1;
|
dls.want_authority = 1;
|
||||||
/* client */
|
/* client */
|
||||||
mock_options->ClientOnly = 1;
|
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);
|
client_boot_auth_cons);
|
||||||
mock_options->ClientOnly = 0;
|
mock_options->ClientOnly = 0;
|
||||||
|
|
||||||
/* bridge relay */
|
/* bridge relay */
|
||||||
mock_options->ORPort_set = 1;
|
mock_options->ORPort_set = 1;
|
||||||
mock_options->BridgeRelay = 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);
|
client_boot_auth_cons);
|
||||||
mock_options->ORPort_set = 0;
|
mock_options->ORPort_set = 0;
|
||||||
mock_options->BridgeRelay = 0;
|
mock_options->BridgeRelay = 0;
|
||||||
@ -5527,14 +5527,14 @@ test_dir_find_dl_schedule(void* data)
|
|||||||
dls.want_authority = 0;
|
dls.want_authority = 0;
|
||||||
/* client */
|
/* client */
|
||||||
mock_options->ClientOnly = 1;
|
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);
|
client_boot_fallback_cons);
|
||||||
mock_options->ClientOnly = 0;
|
mock_options->ClientOnly = 0;
|
||||||
|
|
||||||
/* bridge relay */
|
/* bridge relay */
|
||||||
mock_options->ORPort_set = 1;
|
mock_options->ORPort_set = 1;
|
||||||
mock_options->BridgeRelay = 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);
|
client_boot_fallback_cons);
|
||||||
mock_options->ORPort_set = 0;
|
mock_options->ORPort_set = 0;
|
||||||
mock_options->BridgeRelay = 0;
|
mock_options->BridgeRelay = 0;
|
||||||
@ -5543,14 +5543,14 @@ test_dir_find_dl_schedule(void* data)
|
|||||||
/* dls.want_authority is ignored */
|
/* dls.want_authority is ignored */
|
||||||
/* client */
|
/* client */
|
||||||
mock_options->ClientOnly = 1;
|
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);
|
client_boot_auth_only_cons);
|
||||||
mock_options->ClientOnly = 0;
|
mock_options->ClientOnly = 0;
|
||||||
|
|
||||||
/* bridge relay */
|
/* bridge relay */
|
||||||
mock_options->ORPort_set = 1;
|
mock_options->ORPort_set = 1;
|
||||||
mock_options->BridgeRelay = 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);
|
client_boot_auth_only_cons);
|
||||||
mock_options->ORPort_set = 0;
|
mock_options->ORPort_set = 0;
|
||||||
mock_options->BridgeRelay = 0;
|
mock_options->BridgeRelay = 0;
|
||||||
@ -5558,14 +5558,14 @@ test_dir_find_dl_schedule(void* data)
|
|||||||
} else {
|
} else {
|
||||||
/* client */
|
/* client */
|
||||||
mock_options->ClientOnly = 1;
|
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);
|
client_cons);
|
||||||
mock_options->ClientOnly = 0;
|
mock_options->ClientOnly = 0;
|
||||||
|
|
||||||
/* bridge relay */
|
/* bridge relay */
|
||||||
mock_options->ORPort_set = 1;
|
mock_options->ORPort_set = 1;
|
||||||
mock_options->BridgeRelay = 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);
|
client_cons);
|
||||||
mock_options->ORPort_set = 0;
|
mock_options->ORPort_set = 0;
|
||||||
mock_options->BridgeRelay = 0;
|
mock_options->BridgeRelay = 0;
|
||||||
@ -5576,9 +5576,9 @@ test_dir_find_dl_schedule(void* data)
|
|||||||
mock_options->ClientOnly = 1;
|
mock_options->ClientOnly = 1;
|
||||||
mock_options->UseBridges = 1;
|
mock_options->UseBridges = 1;
|
||||||
if (num_bridges_usable(0) > 0) {
|
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 {
|
} 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:
|
done:
|
||||||
@ -5872,14 +5872,14 @@ struct testcase_t dir_tests[] = {
|
|||||||
DIR(dump_unparseable_descriptors, 0),
|
DIR(dump_unparseable_descriptors, 0),
|
||||||
DIR(populate_dump_desc_fifo, 0),
|
DIR(populate_dump_desc_fifo, 0),
|
||||||
DIR(populate_dump_desc_fifo_2, 0),
|
DIR(populate_dump_desc_fifo_2, 0),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "bfd"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bfd"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "bad"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bad"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "cfd"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "cfd"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "cad"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "cad"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "bfr"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bfr"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "bar"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bar"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "cfr"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "cfr"),
|
||||||
DIR_ARG(find_dl_schedule, TT_FORK, "car"),
|
DIR_ARG(find_dl_min_delay, TT_FORK, "car"),
|
||||||
DIR(assumed_flags, 0),
|
DIR(assumed_flags, 0),
|
||||||
DIR(networkstatus_compute_bw_weights_v10, 0),
|
DIR(networkstatus_compute_bw_weights_v10, 0),
|
||||||
DIR(platform_str, 0),
|
DIR(platform_str, 0),
|
||||||
|
Loading…
Reference in New Issue
Block a user