summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-11 11:25:36 -0500
committerNick Mathewson <nickm@torproject.org>2012-12-25 23:10:41 -0500
commita7c6b4ab917085cff23886a97023b92a1c76ca25 (patch)
treed12d3dfe5348410adcb0608dc21e7ce3be72b746
parent68dae4cf3563e536e0693648cefcd0c69e512bff (diff)
downloadtor-a7c6b4ab917085cff23886a97023b92a1c76ca25.tar.gz
tor-a7c6b4ab917085cff23886a97023b92a1c76ca25.zip
Split choosing a regular directory into its own fn
-rw-r--r--src/or/directory.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 198fb6d40f..769e3d1291 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 */
}
}
}