[tor-commits] [tor/master] Split choosing a regular directory into its own fn

nickm at torproject.org nickm at torproject.org
Wed Dec 26 04:24:01 UTC 2012


commit a7c6b4ab917085cff23886a97023b92a1c76ca25
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Dec 11 11:25:36 2012 -0500

    Split choosing a regular directory into its own fn
---
 src/or/directory.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 198fb6d..769e3d1 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -334,6 +334,24 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
   }
 }
 
+/**DOCDOC*/
+static const routerstatus_t *
+directory_pick_generic_dirserver(dirinfo_type_t type, int pds_flags,
+                                 uint8_t dir_purpose)
+{
+  const routerstatus_t *rs;
+
+  /* anybody with a non-zero dirport will do */
+  rs = router_pick_directory_server(type, pds_flags);
+  if (!rs) {
+    log_info(LD_DIR, "No router found for %s; falling back to "
+             "dirserver list.", dir_conn_purpose_to_string(dir_purpose));
+    rs = router_pick_fallback_dirserver(type, pds_flags);
+  }
+
+  return rs;
+}
+
 /** Start a connection to a random running directory server, using
  * connection purpose <b>dir_purpose</b>, intending to fetch descriptors
  * of purpose <b>router_purpose</b>, and requesting <b>resource</b>.
@@ -469,14 +487,13 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
         }
       }
       if (!rs && type != BRIDGE_DIRINFO) {
-        /* anybody with a non-zero dirport will do */
-        rs = router_pick_directory_server(type, pds_flags);
+        /* */
+        rs = directory_pick_generic_dirserver(type, pds_flags,
+                                              dir_purpose);
         if (!rs) {
-          log_info(LD_DIR, "No router found for %s; falling back to "
-                   "dirserver list.", dir_conn_purpose_to_string(dir_purpose));
-          rs = router_pick_fallback_dirserver(type, pds_flags);
-          if (!rs)
-            get_via_tor = 1; /* last resort: try routing it via Tor */
+          /*XXXX024 I'm pretty sure this can never do any good, since
+           * rs isn't set. */
+          get_via_tor = 1; /* last resort: try routing it via Tor */
         }
       }
     }





More information about the tor-commits mailing list