aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2010-04-21 03:12:14 -0400
committerRoger Dingledine <arma@torproject.org>2010-04-21 03:12:14 -0400
commit4f307e038272e368cd307ffa5e31b568b0729c48 (patch)
treee4610ee1eb11c869440d81ac57b88963ad3ac327 /src/or/dirserv.c
parent7231e289dd93d6aa3d17c46fd8ae44e70b365980 (diff)
downloadtor-4f307e038272e368cd307ffa5e31b568b0729c48.tar.gz
tor-4f307e038272e368cd307ffa5e31b568b0729c48.zip
immediate reachability check for new relays
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index b5c4c7b506..ad96e7670f 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -3091,6 +3091,23 @@ dirserv_orconn_tls_done(const char *address,
* skip testing. */
}
+/** Helper function for dirserv_test_reachability(). Start a TLS
+ * connection to <b>router</b>, and annotate it with when we started
+ * the test. */
+void
+dirserv_single_reachability_test(time_t now, routerinfo_t *router)
+{
+ tor_addr_t router_addr;
+ log_debug(LD_OR,"Testing reachability of %s at %s:%u.",
+ router->nickname, router->address, router->or_port);
+ /* Remember when we started trying to determine reachability */
+ if (!router->testing_since)
+ router->testing_since = now;
+ tor_addr_from_ipv4h(&router_addr, router->addr);
+ connection_or_connect(&router_addr, router->or_port,
+ router->cache_info.identity_digest);
+}
+
/** Auth dir server only: if <b>try_all</b> is 1, launch connections to
* all known routers; else we want to load balance such that we only
* try a few connections per call.
@@ -3117,7 +3134,6 @@ dirserv_test_reachability(time_t now, int try_all)
SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, router) {
const char *id_digest = router->cache_info.identity_digest;
- tor_addr_t router_addr;
if (router_is_me(router))
continue;
if (bridge_auth && router->purpose != ROUTER_PURPOSE_BRIDGE)
@@ -3125,13 +3141,7 @@ dirserv_test_reachability(time_t now, int try_all)
// if (router->cache_info.published_on > cutoff)
// continue;
if (try_all || (((uint8_t)id_digest[0]) % 128) == ctr) {
- log_debug(LD_OR,"Testing reachability of %s at %s:%u.",
- router->nickname, router->address, router->or_port);
- /* Remember when we started trying to determine reachability */
- if (!router->testing_since)
- router->testing_since = now;
- tor_addr_from_ipv4h(&router_addr, router->addr);
- connection_or_connect(&router_addr, router->or_port, id_digest);
+ dirserv_single_reachability_test(now, router);
}
} SMARTLIST_FOREACH_END(router);
if (!try_all) /* increment ctr */