[or-cvs] Get rid of the router_retry_connections notion. Now routers...
arma at seul.org
arma at seul.org
Tue Jul 4 03:31:29 UTC 2006
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv6512
Modified Files:
dirserv.c main.c or.h router.c
Log Message:
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.
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.352
retrieving revision 1.353
diff -u -p -d -r1.352 -r1.353
--- dirserv.c 29 Jun 2006 11:19:52 -0000 1.352
+++ dirserv.c 4 Jul 2006 03:31:27 -0000 1.353
@@ -1784,6 +1784,39 @@ dirserv_orconn_tls_done(const char *addr
}
}
+/** 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
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.648
retrieving revision 1.649
diff -u -p -d -r1.648 -r1.649
--- main.c 15 Jun 2006 09:03:15 -0000 1.648
+++ main.c 4 Jul 2006 03:31:27 -0000 1.649
@@ -568,13 +568,9 @@ directory_info_has_arrived(time_t now, i
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())) {
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.846
retrieving revision 1.847
diff -u -p -d -r1.846 -r1.847
--- or.h 22 Jun 2006 07:01:54 -0000 1.846
+++ or.h 4 Jul 2006 03:31:27 -0000 1.847
@@ -1956,6 +1956,7 @@ void dirserv_orconn_tls_done(const char
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);
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -p -d -r1.267 -r1.268
--- router.c 22 Jun 2006 07:01:54 -0000 1.267
+++ router.c 4 Jul 2006 03:31:27 -0000 1.268
@@ -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,57 +608,8 @@ consider_publishable_server(int force)
}
/*
- * Clique maintenance
- */
-
-/** 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).
+ * Clique maintenance -- to be phased out.
*/
-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. */
More information about the tor-commits
mailing list