[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] balance the reachability testing so a smidgen of it happens



Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	dirserv.c main.c or.h router.c 
Log Message:
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.


Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.289
retrieving revision 1.290
diff -u -p -d -r1.289 -r1.290
--- dirserv.c	10 Jan 2006 04:57:12 -0000	1.289
+++ dirserv.c	10 Jan 2006 07:21:01 -0000	1.290
@@ -686,8 +686,8 @@ list_single_server_status(routerinfo_t *
   return tor_strdup(buf);
 }
 
-#define REACHABLE_TIMEOUT (60*60) /* an hour */
-/* Make sure this is 3 times the value of get_dir_fetch_period() */
+#define REACHABLE_TIMEOUT (90*60) /* ninety minutes */
+/* Make sure this is at least 3 times the value of get_dir_fetch_period() */
 
 /** Treat a router as alive if
  *    - It's me, and I'm not hibernating.

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.610
retrieving revision 1.611
diff -u -p -d -r1.610 -r1.611
--- main.c	7 Jan 2006 03:56:56 -0000	1.610
+++ main.c	10 Jan 2006 07:21:01 -0000	1.611
@@ -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
 get_dir_fetch_period(or_options_t *options)
@@ -573,7 +573,7 @@ directory_info_has_arrived(time_t now, i
   if (server_mode(options) &&
       !we_are_hibernating()) { /* connect to the appropriate routers */
     if (!authdir_mode(options))
-      router_retry_connections(0);
+      router_retry_connections(0, 1);
     if (!from_cache)
       consider_testing_reachability();
   }
@@ -768,6 +768,11 @@ run_scheduled_events(time_t now)
   if (accounting_is_enabled(options))
     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
    * new running-routers list, and/or force-uploading our descriptor
    * (if we've passed our internal checks). */
@@ -776,12 +781,6 @@ run_scheduled_events(time_t now)
     routerlist_remove_old_routers();
     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. */
     if (options->DirPort && !options->V1AuthoritativeDir) {
       directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
@@ -1108,7 +1107,7 @@ do_main_loop(void)
 
   if (authdir_mode(get_options())) {
     /* the directory is already here, run startup things */
-    router_retry_connections(1);
+    router_retry_connections(1, 1);
   }
 
   if (server_mode(get_options())) {

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.777
retrieving revision 1.778
diff -u -p -d -r1.777 -r1.778
--- or.h	10 Jan 2006 04:57:12 -0000	1.777
+++ or.h	10 Jan 2006 07:21:01 -0000	1.778
@@ -2195,7 +2195,7 @@ int server_mode(or_options_t *options);
 int advertised_server_mode(void);
 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);
 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: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -p -d -r1.238 -r1.239
--- router.c	8 Jan 2006 22:16:09 -0000	1.238
+++ router.c	10 Jan 2006 07:21:01 -0000	1.239
@@ -610,15 +610,20 @@ consider_publishable_server(time_t now, 
  * 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