diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-12-16 20:04:49 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-12-16 20:04:49 -0500 |
commit | b9714e1366a19dff1f9abe18a22dc4367788cc3c (patch) | |
tree | 6badd97223a7ca313a6f3ed5591952f0c713801f /src/or | |
parent | e6be486aea1a102d73c4432340c533eea80740e1 (diff) | |
parent | 1b704979488fad24bc439b52e7392e6936955577 (diff) | |
download | tor-b9714e1366a19dff1f9abe18a22dc4367788cc3c.tar.gz tor-b9714e1366a19dff1f9abe18a22dc4367788cc3c.zip |
Merge remote-tracking branch 'teor/fix-multi-dir'
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/networkstatus.c | 14 | ||||
-rw-r--r-- | src/or/router.c | 8 | ||||
-rw-r--r-- | src/or/router.h | 5 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 173c109d60..0cf8873f03 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1286,25 +1286,29 @@ networkstatus_consensus_is_boostrapping(time_t now) } /** Check if we can use multiple directories for a consensus download. - * Only clients (including bridges, but excluding bridge clients) benefit + * Only clients (including bridge relays, which act like clients) benefit * from multiple simultaneous consensus downloads. */ int networkstatus_consensus_can_use_multiple_directories( const or_options_t *options) { /* If we are a client, bridge, bridge client, or hidden service */ - return (!directory_fetches_from_authorities(options)); + return !public_server_mode(options); } /** Check if we can use fallback directory mirrors for a consensus download. - * Only clients that have a list of additional fallbacks can use fallbacks. */ + * If we have fallbacks and don't want to fetch from the authorities, + * we can use them. */ int networkstatus_consensus_can_use_extra_fallbacks(const or_options_t *options) { - /* If we are a client, and we have additional mirrors, we can use them. - * The list length comparisons are a quick way to check if we have any + /* The list length comparisons are a quick way to check if we have any * non-authority fallback directories. If we ever have any authorities that * aren't fallback directories, we will need to change this code. */ + tor_assert(smartlist_len(router_get_fallback_dir_servers()) + >= smartlist_len(router_get_trusted_dir_servers())); + /* If we don't fetch from the authorities, and we have additional mirrors, + * we can use them. */ return (!directory_fetches_from_authorities(options) && (smartlist_len(router_get_fallback_dir_servers()) > smartlist_len(router_get_trusted_dir_servers()))); diff --git a/src/or/router.c b/src/or/router.c index 49e2e318f5..c35f629f30 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1457,8 +1457,8 @@ static int server_is_advertised=0; /** Return true iff we have published our descriptor lately. */ -int -advertised_server_mode(void) +MOCK_IMPL(int, +advertised_server_mode,(void)) { return server_is_advertised; } @@ -1820,8 +1820,8 @@ static int router_guess_address_from_dir_headers(uint32_t *guess); * it's configured in torrc, or because we've learned it from * dirserver headers. Place the answer in *<b>addr</b> and return * 0 on success, else return -1 if we have no guess. */ -int -router_pick_published_address(const or_options_t *options, uint32_t *addr) +MOCK_IMPL(int, +router_pick_published_address,(const or_options_t *options, uint32_t *addr)) { *addr = get_last_resolved_addr(); if (!*addr && diff --git a/src/or/router.h b/src/or/router.h index 85f43d804d..a4b3e9616c 100644 --- a/src/or/router.h +++ b/src/or/router.h @@ -67,7 +67,7 @@ uint16_t router_get_advertised_dir_port(const or_options_t *options, MOCK_DECL(int, server_mode, (const or_options_t *options)); MOCK_DECL(int, public_server_mode, (const or_options_t *options)); -int advertised_server_mode(void); +MOCK_DECL(int, advertised_server_mode, (void)); int proxy_mode(const or_options_t *options); void consider_publishable_server(int force); int should_refuse_unknown_exits(const or_options_t *options); @@ -89,7 +89,8 @@ int router_digest_is_me(const char *digest); const uint8_t *router_get_my_id_digest(void); int router_extrainfo_digest_is_me(const char *digest); int router_is_me(const routerinfo_t *router); -int router_pick_published_address(const or_options_t *options, uint32_t *addr); +MOCK_DECL(int,router_pick_published_address,(const or_options_t *options, + uint32_t *addr)); int router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e); int router_rebuild_descriptor(int force); char *router_dump_router_to_string(routerinfo_t *router, |