aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2009-10-01 04:15:45 -0400
committerRoger Dingledine <arma@torproject.org>2009-10-01 04:15:45 -0400
commit9325b9269cbfce462c831d356059c1932e09f3d3 (patch)
tree880c98d221f2bded39ffef0efc5b47fa33e13c40 /src
parentb9e8f0a0132d52fc62889a07e17a7e67abc251a1 (diff)
downloadtor-9325b9269cbfce462c831d356059c1932e09f3d3.tar
tor-9325b9269cbfce462c831d356059c1932e09f3d3.tar.gz
Ignore one-hop circuits for circuit timeout calc
Don't count one-hop circuits when we're estimating how long it takes circuits to build on average. Otherwise we'll set our circuit build timeout lower than we should. Bugfix on 0.2.2.2-alpha.
Diffstat (limited to 'src')
-rw-r--r--src/or/circuitbuild.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 2e3465d6f..1bf16e8b4 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -204,21 +204,18 @@ circuit_build_times_rewind_history(circuit_build_times_t *cbt, int n)
}
/**
- * Add a timeoutout value to the set of build times. Time units
- * are milliseconds
+ * Add a new timeout value <b>time</b> to the set of build times. Time
+ * units are milliseconds.
*
- * circuit_build_times is a circular array, so loop around when
+ * circuit_build_times <b>cbt</a> is a circular array, so loop around when
* array is full.
*/
int
circuit_build_times_add_time(circuit_build_times_t *cbt, build_time_t time)
{
- if (time > BUILD_TIME_MAX) {
- log_notice(LD_CIRC,
- "Circuit build time of %ums exceeds max. Capping at 65536ms", time);
- time = BUILD_TIME_MAX;
- } else if (time <= 0) {
- log_err(LD_CIRC, "Circuit build time is %u!", time);
+ tor_assert(time <= BUILD_TIME_MAX);
+ if (time <= 0) {
+ log_warn(LD_CIRC, "Circuit build time is %u!", time);
return -1;
}
@@ -627,10 +624,10 @@ circuit_build_times_add_timeout_worker(circuit_build_times_t *cbt,
"%ums vs %lfms using Xm: %d a: %lf, q: %lf",
gentime, cbt->timeout_ms, cbt->Xm, cbt->alpha, quantile_cutoff);
} else if (gentime > BUILD_TIME_MAX) {
- gentime = BUILD_TIME_MAX;
log_info(LD_CIRC,
"Generated a synthetic timeout larger than the max: %u",
gentime);
+ gentime = BUILD_TIME_MAX;
} else {
log_info(LD_CIRC, "Generated synthetic circuit build time %u for timeout",
gentime);
@@ -1506,17 +1503,19 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
log_debug(LD_CIRC,"starting to send subsequent skin.");
hop = onion_next_hop_in_cpath(circ->cpath);
if (!hop) {
- struct timeval end;
- long timediff;
- tor_gettimeofday(&end);
- timediff = tv_mdiff(&circ->_base.highres_created, &end);
- if (timediff > INT32_MAX)
- timediff = INT32_MAX;
/* done building the circuit. whew. */
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_OPEN);
- circuit_build_times_add_time(&circ_times, (build_time_t)timediff);
- circuit_build_times_network_circ_success(&circ_times);
- circuit_build_times_set_timeout(&circ_times);
+ if (!circ->build_state->onehop_tunnel) {
+ struct timeval end;
+ long timediff;
+ tor_gettimeofday(&end);
+ timediff = tv_mdiff(&circ->_base.highres_created, &end);
+ if (timediff > BUILD_TIME_MAX)
+ timediff = BUILD_TIME_MAX;
+ circuit_build_times_add_time(&circ_times, (build_time_t)timediff);
+ circuit_build_times_network_circ_success(&circ_times);
+ circuit_build_times_set_timeout(&circ_times);
+ }
log_info(LD_CIRC,"circuit built!");
circuit_reset_failure_count(0);
if (circ->build_state->onehop_tunnel)