summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2017-12-11 01:14:28 +1100
committerNick Mathewson <nickm@torproject.org>2017-12-12 19:17:25 -0500
commit6b5c70670b26b9560febf5dc70f814d5e515c0f8 (patch)
tree9a400adea1a6dc6a87b336e91bb1a617f49d8e2a
parent6f3a862966cd09b9feae357ada0ad4d51b51c0ea (diff)
downloadtor-6b5c70670b26b9560febf5dc70f814d5e515c0f8.tar.gz
tor-6b5c70670b26b9560febf5dc70f814d5e515c0f8.zip
Simplify some conditionals in circuit_get_open_circ_or_launch()
When entry_list_is_constrained() is true, guards_retry_optimistic() always returns true. When entry_list_is_constrained() is false, options->UseBridges is always false, therefore !options->UseBridges is always true, therefore (!options->UseBridges || ...) is always true. Cleanup after #24367.
-rw-r--r--src/or/circuituse.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 8c9859bab7..34b2e2eabe 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -2075,8 +2075,12 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
if (!connection_get_by_type(CONN_TYPE_DIR)) {
int severity = LOG_NOTICE;
/* Retry some stuff that might help the connection work. */
- if (entry_list_is_constrained(options) &&
- guards_retry_optimistic(options)) {
+ /* If we are configured with EntryNodes or UseBridges */
+ if (entry_list_is_constrained(options)) {
+ /* Retry all our guards / bridges.
+ * guards_retry_optimistic() always returns true here. */
+ int rv = guards_retry_optimistic(options);
+ tor_assert_nonfatal_once(rv);
log_fn(severity, LD_APP|LD_DIR,
"Application request when we haven't %s. "
"Optimistically trying known %s again.",
@@ -2084,7 +2088,12 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
"used client functionality lately" :
"received a consensus with exits",
options->UseBridges ? "bridges" : "entrynodes");
- } else if (!options->UseBridges || num_bridges_usable() > 0) {
+ } else {
+ /* Getting directory documents doesn't help much if we have a limited
+ * number of guards */
+ tor_assert_nonfatal(!options->UseBridges);
+ tor_assert_nonfatal(!options->EntryNodes);
+ /* Retry our directory fetches, so we have a fresh set of guard info */
log_fn(severity, LD_APP|LD_DIR,
"Application request when we haven't %s. "
"Optimistically trying directory fetches again.",