summaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2017-11-22 01:50:46 +1100
committerteor <teor2345@gmail.com>2017-11-22 02:00:34 +1100
commit690f646bf8a5de9b099fb5295ba9ff252e5606f4 (patch)
treee45732bbcfbcde8fc5b3aa384f13ffc7a2d65cd3 /src/test/test_dir.c
parentda82e0b5795c449f4442c87e065e9a60da4892a8 (diff)
downloadtor-690f646bf8a5de9b099fb5295ba9ff252e5606f4.tar.gz
tor-690f646bf8a5de9b099fb5295ba9ff252e5606f4.zip
Stop checking cached bridge descriptors for usable bridges
Stop checking for bridge descriptors when we actually want to know if any bridges are usable. This avoids potential bootstrapping issues. Fixes bug 24367; bugfix on 0.2.0.3-alpha. Stop stalling when bridges are changed at runtime. Stop stalling when old bridge descriptors are cached, but they are not in use. Fixes bug 24367; bugfix on 23347 in 0.3.2.1-alpha.
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index ee4a9780b1..78bf23608a 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -5875,11 +5875,11 @@ mock_networkstatus_consensus_can_use_extra_fallbacks(
return mock_networkstatus_consensus_can_use_extra_fallbacks_value;
}
-static int mock_any_bridge_descriptors_known_value = 0;
+static int mock_num_bridges_usable_value = 0;
static int
-mock_any_bridge_descriptors_known(void)
+mock_num_bridges_usable(void)
{
- return mock_any_bridge_descriptors_known_value;
+ return mock_num_bridges_usable_value;
}
/* data is a 3 character nul-terminated string.
@@ -5908,17 +5908,18 @@ test_dir_find_dl_schedule(void* data)
}
if (str[2] == 'r') {
- mock_any_bridge_descriptors_known_value = 1;
+ /* Any positive, non-zero value should work */
+ mock_num_bridges_usable_value = 2;
} else {
- mock_any_bridge_descriptors_known_value = 0;
+ mock_num_bridges_usable_value = 0;
}
MOCK(networkstatus_consensus_is_bootstrapping,
mock_networkstatus_consensus_is_bootstrapping);
MOCK(networkstatus_consensus_can_use_extra_fallbacks,
mock_networkstatus_consensus_can_use_extra_fallbacks);
- MOCK(any_bridge_descriptors_known,
- mock_any_bridge_descriptors_known);
+ MOCK(num_bridges_usable,
+ mock_num_bridges_usable);
download_status_t dls;
smartlist_t server, client, server_cons, client_cons;
@@ -6030,7 +6031,7 @@ test_dir_find_dl_schedule(void* data)
/* client */
mock_options->ClientOnly = 1;
mock_options->UseBridges = 1;
- if (any_bridge_descriptors_known()) {
+ if (num_bridges_usable() > 0) {
tt_ptr_op(find_dl_schedule(&dls, mock_options), OP_EQ, &bridge);
} else {
tt_ptr_op(find_dl_schedule(&dls, mock_options), OP_EQ, &bridge_bootstrap);
@@ -6039,7 +6040,7 @@ test_dir_find_dl_schedule(void* data)
done:
UNMOCK(networkstatus_consensus_is_bootstrapping);
UNMOCK(networkstatus_consensus_can_use_extra_fallbacks);
- UNMOCK(any_bridge_descriptors_known);
+ UNMOCK(num_bridges_usable);
UNMOCK(get_options);
tor_free(mock_options);
mock_options = NULL;