aboutsummaryrefslogtreecommitdiff
path: root/src/or/entrynodes.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-07-31 21:48:48 -0400
committerNick Mathewson <nickm@torproject.org>2013-07-31 21:48:48 -0400
commit0a0f93d277046a524740ad110060abf8ed137b8f (patch)
tree6f34c412941a8fb0fbd7e762114eb870b768317b /src/or/entrynodes.c
parent5a5147dd2e5450d783de51d369378c59957733e5 (diff)
parentff6bb13c02b3bb217ac8d48d5a20953f1b188d46 (diff)
downloadtor-0a0f93d277046a524740ad110060abf8ed137b8f.tar.gz
tor-0a0f93d277046a524740ad110060abf8ed137b8f.zip
Merge remote-tracking branch 'arma/bug9354' into maint-0.2.4
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r--src/or/entrynodes.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 7a1f67d16a..f1af75aefb 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -415,14 +415,24 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend,
return node;
}
+/** Choose how many entry guards or directory guards we'll use. If
+ * <b>for_directory</b> is true, we return how many directory guards to
+ * use; else we return how many entry guards to use. */
+static int
+decide_num_guards(const or_options_t *options, int for_directory)
+{
+ if (for_directory && options->NumDirectoryGuards != 0)
+ return options->NumDirectoryGuards;
+ return options->NumEntryGuards;
+}
+
/** If the use of entry guards is configured, choose more entry guards
* until we have enough in the list. */
static void
pick_entry_guards(const or_options_t *options, int for_directory)
{
int changed = 0;
- const int num_needed = for_directory ? options->NumDirectoryGuards :
- options->NumEntryGuards;
+ const int num_needed = decide_num_guards(options, for_directory);
tor_assert(entry_guards);
@@ -962,8 +972,7 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory,
int need_capacity = state ? state->need_capacity : 0;
int preferred_min, consider_exit_family = 0;
int need_descriptor = !for_directory;
- const int num_needed = for_directory ? options->NumDirectoryGuards :
- options->NumEntryGuards;
+ const int num_needed = decide_num_guards(options, for_directory);
if (chosen_exit) {
nodelist_add_node_and_family(exit_family, chosen_exit);