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

[or-cvs] [tor/master 02/10] Fix state checks on liveness handling.



Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Wed, 29 Sep 2010 08:47:35 -0700
Subject: Fix state checks on liveness handling.
Commit: 0744a175afa559435bd0e3cdb53891282469e0ee

If we really want all this complexity for these stages here, we need to handle
it better for people with large timeouts. It should probably go away, though.
---
 src/or/circuitbuild.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 4f4d9c7..81b63fe 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1034,17 +1034,25 @@ circuit_build_times_network_check_live(circuit_build_times_t *cbt)
     return 0;
   } else if (cbt->liveness.nonlive_timeouts >=
                 CBT_NETWORK_NONLIVE_TIMEOUT_COUNT) {
-    // XXX: We won't ever conclude the network is flaky here for poor arma...
-    if (cbt->timeout_ms < circuit_build_times_get_initial_timeout()) {
+    if (cbt->liveness.suspended_timeout <= 0) {
+      cbt->liveness.suspended_timeout = cbt->timeout_ms;
+      cbt->liveness.suspended_close_timeout = cbt->close_ms;
+
+      if (cbt->timeout_ms < circuit_build_times_get_initial_timeout())
+        cbt->timeout_ms = circuit_build_times_get_initial_timeout();
+      else
+        cbt->timeout_ms *= 2;
+
+      if (cbt->close_ms < circuit_build_times_get_initial_timeout())
+        cbt->close_ms = circuit_build_times_get_initial_timeout();
+      else
+        cbt->close_ms *= 2;
+
       log_notice(LD_CIRC,
                 "Network is flaky. No activity for %ld seconds. "
                 "Temporarily raising timeout to %lds.",
                 (long int)(now - cbt->liveness.network_last_live),
-                tor_lround(circuit_build_times_get_initial_timeout()/1000));
-      cbt->liveness.suspended_timeout = cbt->timeout_ms;
-      cbt->liveness.suspended_close_timeout = cbt->close_ms;
-      cbt->close_ms = cbt->timeout_ms
-                    = circuit_build_times_get_initial_timeout();
+                tor_lround(cbt->timeout_ms/1000));
       control_event_buildtimeout_set(cbt, BUILDTIMEOUT_SET_EVENT_SUSPENDED);
     }
 
-- 
1.7.1