From d7089ff228227259137b5a8bc32d0764a0ad4155 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 12 Feb 2013 16:23:12 -0500 Subject: Restore the entry/dirguard distinction. We shouldn't be calling choose_random_entry() for directory conncetions; that's what choose_random_dirguard() is for. --- src/or/entrynodes.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/or/entrynodes.c') diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index dab081d1fc..51c3a56742 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -848,6 +848,14 @@ node_understands_microdescriptors(const node_t *node) static int node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo) { + /* Checking dirinfo for any type other than microdescriptors isn't required + yet, since we only choose directory guards that can support microdescs, + routerinfos, and networkstatuses, AND we don't use directory guards if + we're configured to do direct downloads of anything else. The only case + where we might have a guard that doesn't know about a type of directory + information is when we're retrieving directory information from a + bridge. */ + if ((dirinfo & MICRODESC_DIRINFO) && !node_understands_microdescriptors(node)) return 0; @@ -862,9 +870,9 @@ node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo) * only select from nodes that know how to answer directory questions * of that type. */ const node_t * -choose_random_entry(cpath_build_state_t *state, dirinfo_type_t dirinfo) +choose_random_entry(cpath_build_state_t *state) { - return choose_random_entry_impl(state, 0, dirinfo); + return choose_random_entry_impl(state, 0, 0); } /** Pick a live (up and listed) directory guard from entry_guards for @@ -893,12 +901,6 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory, const int num_needed = for_directory ? options->NumDirectoryGuards : options->NumEntryGuards; - /* Checking dirinfo_type isn't required yet, since we only choose directory - guards that can support microdescs, routerinfos, and networkstatuses, AND - we don't use directory guards if we're configured to do direct downloads - of anything else. */ - (void) dirinfo_type; - if (chosen_exit) { nodelist_add_node_and_family(exit_family, chosen_exit); consider_exit_family = 1; @@ -2012,7 +2014,7 @@ int any_bridge_descriptors_known(void) { tor_assert(get_options()->UseBridges); - return choose_random_entry(NULL, NO_DIRINFO)!=NULL ? 1 : 0; + return choose_random_entry(NULL) != NULL; } /** Return 1 if there are any directory conns fetching bridge descriptors -- cgit v1.2.3-54-g00ecf