[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [tor/master 10/28] Fix comments from Sebastian + Nick's code review.
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Mon, 10 May 2010 19:56:27 -0700
Subject: Fix comments from Sebastian + Nick's code review.
Commit: a5ac96b58d17ff14e63ae714f117c04d23c44215
Check for overflow in one place, and be consistent about type usage.
---
src/or/circuitbuild.c | 11 ++++++++---
src/or/or.h | 5 +++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 4f79d32..1d4d267 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -955,7 +955,7 @@ circuit_build_times_network_check_live(circuit_build_times_t *cbt)
}
return 0;
- } else if (cbt->liveness.suspended_timeout) {
+ } else if (cbt->liveness.suspended_timeout > 0) {
log_notice(LD_CIRC,
"Network activity has resumed. "
"Resuming circuit timeout calculations.");
@@ -1004,7 +1004,12 @@ circuit_build_times_network_check_changed(circuit_build_times_t *cbt)
/* Check to see if this has happened before. If so, double the timeout
* to give people on abysmally bad network connections a shot at access */
if (cbt->timeout_ms >= circuit_build_times_get_initial_timeout()) {
- cbt->timeout_ms *= 2;
+ if (cbt->timeout_ms > INT32_MAX/2) {
+ log_warn(LD_CIRC, "Insanely large circuit build timeout value: %lf",
+ cbt->timeout_ms);
+ } else {
+ cbt->timeout_ms *= 2;
+ }
} else {
cbt->timeout_ms = circuit_build_times_get_initial_timeout();
}
@@ -1100,7 +1105,7 @@ circuit_build_times_filter_timeouts(circuit_build_times_t *cbt)
}
timeout_rate = circuit_build_times_timeout_rate(cbt);
- max_timeout = tor_lround(circuit_build_times_calculate_timeout(cbt,
+ max_timeout = (build_time_t)tor_lround(circuit_build_times_calculate_timeout(cbt,
circuit_build_times_max_synthetic_quantile()));
for (i = 0; i < CBT_NCIRCUITS_TO_OBSERVE; i++) {
diff --git a/src/or/or.h b/src/or/or.h
index 36c45e2..7b1982a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3113,7 +3113,7 @@ typedef struct {
int after_firsthop_idx;
/** Timeout gathering is suspended if non-zero. The old timeout value
* is stored here in that case. */
- build_time_t suspended_timeout;
+ double suspended_timeout;
} network_liveness_t;
/** Structure for circuit build times history */
@@ -3137,7 +3137,8 @@ typedef struct {
double alpha;
/** Have we computed a timeout? */
int have_computed_timeout;
- /** The exact value for that timeout in milliseconds */
+ /** The exact value for that timeout in milliseconds. Stored as a double
+ * to maintain precision from calculations to and from quantile value. */
double timeout_ms;
} circuit_build_times_t;
--
1.7.1