diff options
author | Roger Dingledine <arma@torproject.org> | 2006-01-10 07:21:01 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2006-01-10 07:21:01 +0000 |
commit | c8e6003412300a235ae51d959d8a9bea63724a90 (patch) | |
tree | b83a0fdb682a19a03337ee28826b68d1d1e92c03 /src/or/router.c | |
parent | 43a4f8c7f301a9e83214b9cbff856b378edfe66b (diff) | |
download | tor-c8e6003412300a235ae51d959d8a9bea63724a90.tar tor-c8e6003412300a235ae51d959d8a9bea63724a90.tar.gz |
balance the reachability testing so a smidgen of it happens
every 10 seconds. this way we don't try to do 500 tls's at
once every 20 minutes.
svn:r5763
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/or/router.c b/src/or/router.c index f3600ec94..916b18a11 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -610,15 +610,20 @@ consider_publishable_server(time_t now, int force) * other ORs we know about. Otherwise, open connections to those we * think are in clique mode. * - * If <b>force</b> is zero, only open the connection if we don't already - * have one. + * If <b>testing_reachability</b> is 0, try to open the connections + * but only if we don't already have one. If it's 1, then we're an + * auth dir server, and we should try to connect regardless of + * whether we already have a connection open -- but if <b>try_all</b> + * is 0, we want to load balance such that we only try a few connections + * per call. */ void -router_retry_connections(int force) +router_retry_connections(int testing_reachability, int try_all) { time_t now = time(NULL); routerlist_t *rl = router_get_routerlist(); or_options_t *options = get_options(); + static char ctr = 0; tor_assert(server_mode(options)); @@ -628,8 +633,10 @@ router_retry_connections(int force) continue; if (!clique_mode(options) && !router_is_clique_mode(router)) continue; - if (force || - !connection_or_get_by_identity_digest(id_digest)) { + if ((testing_reachability && + (try_all || (((uint8_t)id_digest[0]) % 128) == ctr)) || + (!testing_reachability && + !connection_or_get_by_identity_digest(id_digest))) { debug(LD_OR,"%sconnecting to %s at %s:%u.", clique_mode(options) ? "(forced) " : "", router->nickname, router->address, router->or_port); @@ -640,6 +647,8 @@ router_retry_connections(int force) id_digest); } }); + if (testing_reachability && !try_all) /* increment ctr */ + ctr = (ctr + 1) % 128; } /** Return true iff this OR should try to keep connections open to all |