Get rid of the router_retry_connections notion. Now routers no longer

try to rebuild long-term connections to directory authorities, and
directory authorities no longer try to rebuild long-term connections to
all servers.

We still don't hang up connections in these two cases though -- we need
to look at it more carefully to avoid flapping, and we likely need to
wait til 0.1.1.x is obsolete.


svn:r6712
This commit is contained in:
Roger Dingledine 2006-07-04 03:31:27 +00:00
parent ff1b4764e9
commit 05d0b70573
4 changed files with 47 additions and 70 deletions

View File

@ -1784,6 +1784,39 @@ dirserv_orconn_tls_done(const char *address,
}
}
/** 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.
*
* The load balancing is such that if we get called once every ten
* seconds, we will cycle through all the tests in 1280 seconds (a
* bit over 20 minutes).
*/
void
dirserv_test_reachability(int try_all)
{
time_t now = time(NULL);
routerlist_t *rl = router_get_routerlist();
static char ctr = 0;
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, router, {
const char *id_digest = router->cache_info.identity_digest;
if (router_is_me(router))
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;
connection_or_connect(router->addr, router->or_port,
id_digest);
}
});
if (!try_all) /* increment ctr */
ctr = (ctr + 1) % 128;
}
/** When we're spooling data onto our outbuf, add more whenever we dip
* below this threshold. */
#define DIRSERV_BUFFER_MIN 16384

View File

@ -568,13 +568,9 @@ directory_info_has_arrived(time_t now, int from_cache)
return;
}
if (server_mode(options) &&
!we_are_hibernating()) { /* connect to the appropriate routers */
if (!authdir_mode(options))
router_retry_connections(0, 1);
if (!from_cache && has_completed_circuit)
consider_testing_reachability();
}
if (server_mode(options) && !we_are_hibernating() &&
!from_cache && has_completed_circuit)
consider_testing_reachability();
}
/** Perform regular maintenance tasks for a single connection. This
@ -782,7 +778,7 @@ run_scheduled_events(time_t now)
if (now % 10 == 0 && authdir_mode(options) && !we_are_hibernating()) {
/* try to determine reachability */
router_retry_connections(1, 0);
dirserv_test_reachability(0);
}
/** 2. Periodically, we consider getting a new directory, getting a
@ -1134,7 +1130,7 @@ do_main_loop(void)
if (authdir_mode(get_options())) {
/* the directory is already here, run startup things */
router_retry_connections(1, 1);
dirserv_test_reachability(1);
}
if (server_mode(get_options())) {

View File

@ -1956,6 +1956,7 @@ void dirserv_orconn_tls_done(const char *address,
const char *digest_rcvd,
const char *nickname,
int as_advertised);
void dirserv_test_reachability(int try_all);
int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
int complain);
int dirserv_would_reject_router(routerstatus_t *rs);
@ -2271,7 +2272,6 @@ int server_mode(or_options_t *options);
int advertised_server_mode(void);
int proxy_mode(or_options_t *options);
void router_retry_connections(int testing_reachability, int try_all);
int router_is_clique_mode(routerinfo_t *router);
void router_upload_dir_desc_to_dirservers(int force);
void mark_my_descriptor_dirty_if_older_than(time_t when);

View File

@ -372,8 +372,7 @@ init_keys(void)
(uint16_t)options->DirPort, digest,
options->V1AuthoritativeDir);
}
/* success */
return 0;
return 0; /* success */
}
/* Keep track of whether we should upload our server descriptor,
@ -385,13 +384,12 @@ static int can_reach_or_port = 0;
/** Whether we can reach our DirPort from the outside. */
static int can_reach_dir_port = 0;
/** Return 1 if or port is known reachable; else return 0. */
/** Return 1 if ORPort is known reachable; else return 0. */
int
check_whether_orport_reachable(void)
{
or_options_t *options = get_options();
return clique_mode(options) ||
options->AssumeReachable ||
return options->AssumeReachable ||
can_reach_or_port;
}
@ -473,11 +471,10 @@ void
router_orport_found_reachable(void)
{
if (!can_reach_or_port) {
if (!clique_mode(get_options()))
log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from "
"the outside. Excellent.%s",
get_options()->PublishServerDescriptor ?
" Publishing server descriptor." : "");
log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from "
"the outside. Excellent.%s",
get_options()->PublishServerDescriptor ?
" Publishing server descriptor." : "");
can_reach_or_port = 1;
mark_my_descriptor_dirty();
consider_publishable_server(1);
@ -611,58 +608,9 @@ consider_publishable_server(int force)
}
/*
* Clique maintenance
* Clique maintenance -- to be phased out.
*/
/** OR only: if in clique mode, try to open connections to all of the
* other ORs we know about. Otherwise, open connections to those we
* think are in clique mode.
*
* 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.
*
* The load balancing is such that if we get called once every ten
* seconds, we will cycle through all the tests in 1280 seconds (a
* bit over 20 minutes).
*/
void
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));
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, router, {
const char *id_digest = router->cache_info.identity_digest;
if (router_is_me(router))
continue;
if (!clique_mode(options) && !router_is_clique_mode(router))
continue;
if ((testing_reachability &&
(try_all || (((uint8_t)id_digest[0]) % 128) == ctr)) ||
(!testing_reachability &&
!connection_or_get_by_identity_digest(id_digest))) {
log_debug(LD_OR,"%sconnecting to %s at %s:%u.",
clique_mode(options) ? "(forced) " : "",
router->nickname, router->address, router->or_port);
/* Remember when we started trying to determine reachability */
if (!router->testing_since)
router->testing_since = now;
connection_or_connect(router->addr, router->or_port,
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
* other ORs. */
int