[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [tor/release-0.2.2 030/162] Fix non-live condition checks.
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Wed, 29 Sep 2010 11:49:31 -0700
Subject: Fix non-live condition checks.
Commit: 9a77743b7b2e657cb8d9fd413d53cb9e3b8e00ca
Rechecking the timeout condition was foolish, because it is checked on the
same codepath. It was also wrong, because we didn't round.
Also, the liveness check itself should be <, and not <=, because we only have
1 second resolution.
---
src/or/circuitbuild.c | 13 +++++--------
src/or/circuituse.c | 12 +++++-------
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index be435b9..4f4d9c7 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -986,15 +986,8 @@ circuit_build_times_network_close(circuit_build_times_t *cbt,
/*
* 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->close_ms.
- *
- * We use close_ms here because timeouts aren't actually counted as timeouts
- * until close_ms elapses.
*/
- if (cbt->liveness.network_last_live <= start_time &&
- start_time <= (now - cbt->close_ms/1000.0)) {
+ if (cbt->liveness.network_last_live < start_time) {
if (did_onehop) {
char last_live_buf[ISO_TIME_LEN+1];
char start_time_buf[ISO_TIME_LEN+1];
@@ -1009,6 +1002,9 @@ circuit_build_times_network_close(circuit_build_times_t *cbt,
now_buf);
}
cbt->liveness.nonlive_timeouts++;
+ log_info(LD_CIRC,
+ "Got non-live timeout. Current count is: %d",
+ cbt->liveness.nonlive_timeouts);
}
}
@@ -1038,6 +1034,7 @@ 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()) {
log_notice(LD_CIRC,
"Network is flaky. No activity for %ld seconds. "
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index ce03500..6ecb925 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -34,8 +34,6 @@ extern circuit_t *global_circuitlist; /* from circuitlist.c */
static void circuit_expire_old_circuits_clientside(time_t now);
static void circuit_increment_failure_count(void);
-long int lround(double x);
-
/** Return 1 if <b>circ</b> could be returned by circuit_get_best().
* Else return 0.
*/
@@ -282,11 +280,11 @@ circuit_expire_building(time_t now)
circuit_t *victim, *next_circ = global_circuitlist;
/* circ_times.timeout is BUILD_TIMEOUT_INITIAL_VALUE if we haven't
* decided on a customized one yet */
- time_t general_cutoff = now - lround(circ_times.timeout_ms/1000);
- time_t begindir_cutoff = now - lround(circ_times.timeout_ms/2000);
- time_t fourhop_cutoff = now - lround(4*circ_times.timeout_ms/3000);
- time_t cannibalize_cutoff = now - lround(circ_times.timeout_ms/2000);
- time_t close_cutoff = now - lround(circ_times.close_ms/1000);
+ time_t general_cutoff = now - tor_lround(circ_times.timeout_ms/1000);
+ time_t begindir_cutoff = now - tor_lround(circ_times.timeout_ms/2000);
+ time_t fourhop_cutoff = now - tor_lround(4*circ_times.timeout_ms/3000);
+ time_t cannibalize_cutoff = now - tor_lround(circ_times.timeout_ms/2000);
+ time_t close_cutoff = now - tor_lround(circ_times.close_ms/1000);
time_t introcirc_cutoff = begindir_cutoff;
cpath_build_state_t *build_state;
--
1.7.1