mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 20:33:31 +01:00
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
This commit is contained in:
parent
43a4f8c7f3
commit
c8e6003412
@ -686,8 +686,8 @@ list_single_server_status(routerinfo_t *desc, int is_live)
|
|||||||
return tor_strdup(buf);
|
return tor_strdup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define REACHABLE_TIMEOUT (60*60) /* an hour */
|
#define REACHABLE_TIMEOUT (90*60) /* ninety minutes */
|
||||||
/* Make sure this is 3 times the value of get_dir_fetch_period() */
|
/* Make sure this is at least 3 times the value of get_dir_fetch_period() */
|
||||||
|
|
||||||
/** Treat a router as alive if
|
/** Treat a router as alive if
|
||||||
* - It's me, and I'm not hibernating.
|
* - It's me, and I'm not hibernating.
|
||||||
|
@ -523,7 +523,7 @@ directory_all_unreachable(time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the interval to wait betweeen directory downloads, in seconds.
|
* Return the interval to wait between directory downloads, in seconds.
|
||||||
*/
|
*/
|
||||||
static INLINE int
|
static INLINE int
|
||||||
get_dir_fetch_period(or_options_t *options)
|
get_dir_fetch_period(or_options_t *options)
|
||||||
@ -573,7 +573,7 @@ directory_info_has_arrived(time_t now, int from_cache)
|
|||||||
if (server_mode(options) &&
|
if (server_mode(options) &&
|
||||||
!we_are_hibernating()) { /* connect to the appropriate routers */
|
!we_are_hibernating()) { /* connect to the appropriate routers */
|
||||||
if (!authdir_mode(options))
|
if (!authdir_mode(options))
|
||||||
router_retry_connections(0);
|
router_retry_connections(0, 1);
|
||||||
if (!from_cache)
|
if (!from_cache)
|
||||||
consider_testing_reachability();
|
consider_testing_reachability();
|
||||||
}
|
}
|
||||||
@ -768,6 +768,11 @@ run_scheduled_events(time_t now)
|
|||||||
if (accounting_is_enabled(options))
|
if (accounting_is_enabled(options))
|
||||||
accounting_run_housekeeping(now);
|
accounting_run_housekeeping(now);
|
||||||
|
|
||||||
|
if (now % 10 == 0 && authdir_mode(options) && !we_are_hibernating()) {
|
||||||
|
/* try to determine reachability */
|
||||||
|
router_retry_connections(1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/** 2. Periodically, we consider getting a new directory, getting a
|
/** 2. Periodically, we consider getting a new directory, getting a
|
||||||
* new running-routers list, and/or force-uploading our descriptor
|
* new running-routers list, and/or force-uploading our descriptor
|
||||||
* (if we've passed our internal checks). */
|
* (if we've passed our internal checks). */
|
||||||
@ -776,12 +781,6 @@ run_scheduled_events(time_t now)
|
|||||||
routerlist_remove_old_routers();
|
routerlist_remove_old_routers();
|
||||||
networkstatus_list_clean(now);
|
networkstatus_list_clean(now);
|
||||||
|
|
||||||
if (authdir_mode(options)) {
|
|
||||||
if (!we_are_hibernating()) { /* try to determine reachability */
|
|
||||||
router_retry_connections(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only caches actually need to fetch directories now. */
|
/* Only caches actually need to fetch directories now. */
|
||||||
if (options->DirPort && !options->V1AuthoritativeDir) {
|
if (options->DirPort && !options->V1AuthoritativeDir) {
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
|
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
|
||||||
@ -1108,7 +1107,7 @@ do_main_loop(void)
|
|||||||
|
|
||||||
if (authdir_mode(get_options())) {
|
if (authdir_mode(get_options())) {
|
||||||
/* the directory is already here, run startup things */
|
/* the directory is already here, run startup things */
|
||||||
router_retry_connections(1);
|
router_retry_connections(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server_mode(get_options())) {
|
if (server_mode(get_options())) {
|
||||||
|
@ -2195,7 +2195,7 @@ int server_mode(or_options_t *options);
|
|||||||
int advertised_server_mode(void);
|
int advertised_server_mode(void);
|
||||||
int proxy_mode(or_options_t *options);
|
int proxy_mode(or_options_t *options);
|
||||||
|
|
||||||
void router_retry_connections(int force);
|
void router_retry_connections(int testing_reachability, int try_all);
|
||||||
int router_is_clique_mode(routerinfo_t *router);
|
int router_is_clique_mode(routerinfo_t *router);
|
||||||
void router_upload_dir_desc_to_dirservers(int force);
|
void router_upload_dir_desc_to_dirservers(int force);
|
||||||
void mark_my_descriptor_dirty_if_older_than(time_t when);
|
void mark_my_descriptor_dirty_if_older_than(time_t when);
|
||||||
|
@ -610,15 +610,20 @@ consider_publishable_server(time_t now, int force)
|
|||||||
* other ORs we know about. Otherwise, open connections to those we
|
* other ORs we know about. Otherwise, open connections to those we
|
||||||
* think are in clique mode.
|
* think are in clique mode.
|
||||||
*
|
*
|
||||||
* If <b>force</b> is zero, only open the connection if we don't already
|
* If <b>testing_reachability</b> is 0, try to open the connections
|
||||||
* have one.
|
* 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
|
void
|
||||||
router_retry_connections(int force)
|
router_retry_connections(int testing_reachability, int try_all)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
routerlist_t *rl = router_get_routerlist();
|
routerlist_t *rl = router_get_routerlist();
|
||||||
or_options_t *options = get_options();
|
or_options_t *options = get_options();
|
||||||
|
static char ctr = 0;
|
||||||
|
|
||||||
tor_assert(server_mode(options));
|
tor_assert(server_mode(options));
|
||||||
|
|
||||||
@ -628,8 +633,10 @@ router_retry_connections(int force)
|
|||||||
continue;
|
continue;
|
||||||
if (!clique_mode(options) && !router_is_clique_mode(router))
|
if (!clique_mode(options) && !router_is_clique_mode(router))
|
||||||
continue;
|
continue;
|
||||||
if (force ||
|
if ((testing_reachability &&
|
||||||
!connection_or_get_by_identity_digest(id_digest)) {
|
(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.",
|
debug(LD_OR,"%sconnecting to %s at %s:%u.",
|
||||||
clique_mode(options) ? "(forced) " : "",
|
clique_mode(options) ? "(forced) " : "",
|
||||||
router->nickname, router->address, router->or_port);
|
router->nickname, router->address, router->or_port);
|
||||||
@ -640,6 +647,8 @@ router_retry_connections(int force)
|
|||||||
id_digest);
|
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
|
/** Return true iff this OR should try to keep connections open to all
|
||||||
|
Loading…
Reference in New Issue
Block a user