diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-12 19:17:38 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-12 19:17:38 -0500 |
commit | bf89b089306067cffa4d2ca6b7fa7cd54790a961 (patch) | |
tree | a7717d0c55eb662e37f84a63281944caf28ddba5 /src/or/entrynodes.c | |
parent | cf5ab5934e80c6c04825d9db83329627fe6b9729 (diff) | |
parent | 19a4abf2a99c6a3de2c9a2fdf3e6d7b7c404f8f8 (diff) | |
download | tor-bf89b089306067cffa4d2ca6b7fa7cd54790a961.tar.gz tor-bf89b089306067cffa4d2ca6b7fa7cd54790a961.zip |
Merge branch 'bug24367_032_squashed' into maint-0.3.2
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r-- | src/or/entrynodes.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 3959da64cf..67b0259243 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -3136,20 +3136,34 @@ entry_list_is_constrained(const or_options_t *options) } /** Return the number of bridges that have descriptors that are marked with - * purpose 'bridge' and are running. - */ -int -num_bridges_usable(void) + * purpose 'bridge' and are running. If use_maybe_reachable is + * true, include bridges that might be reachable in the count. + * Otherwise, if it is false, only include bridges that have recently been + * found running in the count. + * + * We use this function to decide if we're ready to start building + * circuits through our bridges, or if we need to wait until the + * directory "server/authority" requests finish. */ +MOCK_IMPL(int, +num_bridges_usable,(int use_maybe_reachable)) { int n_options = 0; - tor_assert(get_options()->UseBridges); + if (BUG(!get_options()->UseBridges)) { + return 0; + } guard_selection_t *gs = get_guard_selection_info(); - tor_assert(gs->type == GS_TYPE_BRIDGE); + if (BUG(gs->type != GS_TYPE_BRIDGE)) { + return 0; + } SMARTLIST_FOREACH_BEGIN(gs->sampled_entry_guards, entry_guard_t *, guard) { + /* Definitely not usable */ if (guard->is_reachable == GUARD_REACHABLE_NO) continue; + /* If we want to be really sure the bridges will work, skip maybes */ + if (!use_maybe_reachable && guard->is_reachable == GUARD_REACHABLE_MAYBE) + continue; if (tor_digest_is_zero(guard->identity)) continue; const node_t *node = node_get_by_id(guard->identity); |