diff options
author | Mike Perry <mikeperry-git@fscked.org> | 2010-06-15 18:02:19 -0700 |
---|---|---|
committer | Mike Perry <mikeperry-git@fscked.org> | 2010-06-15 20:04:49 -0700 |
commit | 2abe1ceccfacaa8deca3b7bb4caeb550572efd7f (patch) | |
tree | 121a7b7ab45ff3c0f7e9b40d4cd53921e5492e0d /src/or | |
parent | 82922ea45a24e7f79ac4c1ddf4d9de02c604546d (diff) | |
download | tor-2abe1ceccfacaa8deca3b7bb4caeb550572efd7f.tar.gz tor-2abe1ceccfacaa8deca3b7bb4caeb550572efd7f.zip |
Add CLOSE_MS and CLOSE_RATE keywords to buildtimeout event.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/circuitbuild.c | 19 | ||||
-rw-r--r-- | src/or/control.c | 6 | ||||
-rw-r--r-- | src/or/or.h | 1 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index f244aeaff0..ddc7da4b38 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -1089,6 +1089,25 @@ circuit_build_times_timeout_rate(const circuit_build_times_t *cbt) } /** + * Count the number of closed circuits in a set of cbt data. + */ +double +circuit_build_times_close_rate(const circuit_build_times_t *cbt) +{ + int i=0,closed=0; + for (i = 0; i < CBT_NCIRCUITS_TO_OBSERVE; i++) { + if (cbt->circuit_build_times[i] == CBT_BUILD_ABANDONED) { + closed++; + } + } + + if (!cbt->total_build_times) + return 0; + + return ((double)closed)/cbt->total_build_times; +} + +/** * Store a timeout as a synthetic value. * * Returns true if the store was successful and we should possibly diff --git a/src/or/control.c b/src/or/control.c index b5cc6c7b6d..8cfebe6477 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -3530,11 +3530,13 @@ control_event_buildtimeout_set(const circuit_build_times_t *cbt, send_control_event(EVENT_BUILDTIMEOUT_SET, ALL_FORMATS, "650 BUILDTIMEOUT_SET %s TOTAL_TIMES=%lu " "TIMEOUT_MS=%lu XM=%lu ALPHA=%lf CUTOFF_QUANTILE=%lf " - "TIMEOUT_RATE=%lf\r\n", + "TIMEOUT_RATE=%lf CLOSE_MS=%lu CLOSE_RATE=%lf\r\n", type_string, (unsigned long)cbt->total_build_times, (unsigned long)cbt->timeout_ms, (unsigned long)cbt->Xm, cbt->alpha, qnt, - circuit_build_times_timeout_rate(cbt)); + circuit_build_times_timeout_rate(cbt), + (unsigned long)cbt->close_ms, + circuit_build_times_close_rate(cbt)); return 0; } diff --git a/src/or/or.h b/src/or/or.h index cd6841522b..65468cfe38 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3173,6 +3173,7 @@ void circuit_build_times_init(circuit_build_times_t *cbt); void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt, networkstatus_t *ns); double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt); +double circuit_build_times_close_rate(const circuit_build_times_t *cbt); #ifdef CIRCUIT_PRIVATE double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt, |