aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2010-06-08 01:01:47 -0700
committerMike Perry <mikeperry-git@fscked.org>2010-06-09 00:22:39 -0700
commitc96206090e5090433a7dbb4f5d52ad2efeb00c37 (patch)
tree79ec788d16866d03bcfe2ca89e4333b29ba9c67d /src/or/circuituse.c
parent81736f426fca6fa6cd68b483f9a93b48b2b1f9cf (diff)
downloadtor-c96206090e5090433a7dbb4f5d52ad2efeb00c37.tar
tor-c96206090e5090433a7dbb4f5d52ad2efeb00c37.tar.gz
Keep circuits open until the greater of 95th CDF percentile or 60s.
This is done to provide better data to our right-censored Pareto model. We do this by simply marking them with a new purpose.
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index e7d10a22f..5696d9c6f 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -270,6 +270,7 @@ circuit_expire_building(time_t now)
* 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 close_cutoff = now - lround(circ_times.close_ms/1000);
time_t introcirc_cutoff = begindir_cutoff;
cpath_build_state_t *build_state;
@@ -286,8 +287,11 @@ circuit_expire_building(time_t now)
cutoff = begindir_cutoff;
else if (victim->purpose == CIRCUIT_PURPOSE_C_INTRODUCING)
cutoff = introcirc_cutoff;
+ else if (victim->purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT)
+ cutoff = close_cutoff;
else
cutoff = general_cutoff;
+
if (victim->timestamp_created > cutoff)
continue; /* it's still young, leave it alone */
@@ -350,12 +354,29 @@ circuit_expire_building(time_t now)
} else { /* circuit not open, consider recording failure as timeout */
int first_hop_succeeded = TO_ORIGIN_CIRCUIT(victim)->cpath &&
TO_ORIGIN_CIRCUIT(victim)->cpath->state == CPATH_STATE_OPEN;
+
+ if (TO_ORIGIN_CIRCUIT(victim)->p_streams != NULL) {
+ log_warn(LD_BUG, "Circuit %d (purpose %d) has timed out, "
+ "yet has attached streams!",
+ TO_ORIGIN_CIRCUIT(victim)->global_identifier,
+ victim->purpose);
+ tor_fragile_assert();
+ continue;
+ }
+
+ /* circuits are allowed to last longer for measurement.
+ * Switch their purpose and wait. */
+ if (victim->purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
+ victim->purpose = CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT;
+ continue;
+ }
+
/*
* If the circuit build time is much greater than we would have cut
* it off at, we probably had a suspend event along this codepath,
* and we should discard the value.
*/
- if (now - victim->timestamp_created > (2*circ_times.timeout_ms)/1000+1) {
+ if (now - victim->timestamp_created > 2*circ_times.close_ms/1000+1) {
log_notice(LD_CIRC,
"Extremely large value for circuit build timeout: %ld. "
"Assuming clock jump.", now - victim->timestamp_created);