[or-cvs] [tor/master] Change the condition on the nonlive timeout counting.

arma at seul.org arma at seul.org
Mon Sep 21 02:18:33 UTC 2009


Author: Mike Perry <mikeperry-git at fscked.org>
Date: Sun, 20 Sep 2009 18:20:10 -0700
Subject: Change the condition on the nonlive timeout counting.
Commit: 134266b984ae7a3f591a62cc0328fda270e1885c

Try to clarify things in the comment too.
---
 src/or/circuitbuild.c |   20 +++++++++++++-------
 src/or/test.c         |    6 ++++--
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 6cd4629..b1de024 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -706,18 +706,24 @@ circuit_build_times_network_circ_success(circuit_build_times_t *cbt)
  * at all, but this circuit was launched back when we thought the network
  * was live, increment the number of "nonlive" circuit timeouts.
  *
- * Also distinguish between whether it failed before the first hop.
+ * Also distinguish between whether it failed before the first hop
+ * and record that in our history for later deciding if the network has
+ * changed.
  */
 static void
 circuit_build_times_network_timeout(circuit_build_times_t *cbt,
                                     int did_onehop, time_t start_time)
 {
-  time_t now = approx_time();
-  /* Only count this as a valid attempt if it was both started before
-   * the network was dead and the network has been dead for at least
-   * a full timeout interval. */
-  if (cbt->liveness.network_last_live <= (now - cbt->timeout_ms/1000.0)
-          && cbt->liveness.network_last_live <= start_time) {
+  time_t now = time(NULL);
+  /*
+   * Check if this is a timeout that was for a circuit that spent its
+   * entire existence during a time where we have had no network activity.
+   *
+   * Also double check that it is a valid timeout after we have possibly
+   * just recently reset cbt->timeout_ms.
+   */
+  if (cbt->liveness.network_last_live <= start_time &&
+          start_time <= (now - cbt->timeout_ms/1000.0)) {
     cbt->liveness.nonlive_timeouts++;
   }
 
diff --git a/src/or/test.c b/src/or/test.c
index c2e3401..27ecc47 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -3525,11 +3525,13 @@ test_circuit_timeout(void)
     test_assert(!circuit_build_times_network_check_live(&final));
 
     for ( ; i < NETWORK_NONLIVE_DISCARD_COUNT; i++) {
-      if (circuit_build_times_add_timeout(&estimate, 0, approx_time()))
+      if (circuit_build_times_add_timeout(&estimate, 0,
+                  approx_time()-estimate.timeout_ms/1000.0-1))
         estimate.have_computed_timeout = 1;
 
       if (i < NETWORK_NONLIVE_DISCARD_COUNT-1) {
-        if (circuit_build_times_add_timeout(&final, 0, approx_time()))
+        if (circuit_build_times_add_timeout(&final, 0,
+                  approx_time()-final.timeout_ms/1000.0-1))
           final.have_computed_timeout = 1;
       }
     }
-- 
1.5.6.5



More information about the tor-commits mailing list