diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-12 19:27:14 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-12 19:27:14 -0500 |
commit | 9abef516f609a619b25e8f53a413a2e3df05bde8 (patch) | |
tree | 2b80767e1ad490e20e4e2de034145594173b3171 /src/or/entrynodes.c | |
parent | 13455c0f1a191824d383339c9efcc3b31ecd8e6f (diff) | |
parent | bf89b089306067cffa4d2ca6b7fa7cd54790a961 (diff) | |
download | tor-9abef516f609a619b25e8f53a413a2e3df05bde8.tar.gz tor-9abef516f609a619b25e8f53a413a2e3df05bde8.zip |
Merge branch '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 cbdb36aa43..fa8d62a4f0 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); |