aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2010-09-29 18:01:22 -0400
committerRoger Dingledine <arma@torproject.org>2010-09-29 18:01:22 -0400
commit7f10707c42e69ef69395aecf7984d16107c78331 (patch)
tree0c1c431d27fa11e1fa700743d0c675f1c04110fd /src/or
parentf1b0e4e4b4d238595b1694df201e995bee235960 (diff)
downloadtor-7f10707c42e69ef69395aecf7984d16107c78331.tar
tor-7f10707c42e69ef69395aecf7984d16107c78331.tar.gz
refactor and recomment; no actual changes
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c19
-rw-r--r--src/or/circuitbuild.h1
-rw-r--r--src/or/circuituse.c5
-rw-r--r--src/or/or.h5
4 files changed, 19 insertions, 11 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 7a0a21576..5dfabcc97 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -149,6 +149,14 @@ circuit_build_times_min_circs_to_observe(void)
return num;
}
+/** Return true iff <b>cbt</b> has recorded enough build times that we
+ * want to start acting on the timeout it implies. */
+int
+circuit_build_times_enough_to_compute(circuit_build_times_t *cbt)
+{
+ return cbt->total_build_times >= circuit_build_times_min_circs_to_observe();
+}
+
double
circuit_build_times_quantile_cutoff(void)
{
@@ -292,8 +300,8 @@ circuit_build_times_reset(circuit_build_times_t *cbt)
/**
* Initialize the buildtimes structure for first use.
*
- * Sets the initial timeout value based to either the
- * config setting or BUILD_TIMEOUT_INITIAL_VALUE.
+ * Sets the initial timeout values based on either the config setting,
+ * the consensus param, or the default (CBT_DEFAULT_TIMEOUT_INITIAL_VALUE).
*/
void
circuit_build_times_init(circuit_build_times_t *cbt)
@@ -918,9 +926,7 @@ int
circuit_build_times_needs_circuits(circuit_build_times_t *cbt)
{
/* Return true if < MIN_CIRCUITS_TO_OBSERVE */
- if (cbt->total_build_times < circuit_build_times_min_circs_to_observe())
- return 1;
- return 0;
+ return !circuit_build_times_enough_to_compute(cbt);
}
/**
@@ -1205,9 +1211,8 @@ static int
circuit_build_times_set_timeout_worker(circuit_build_times_t *cbt)
{
build_time_t max_time;
- if (cbt->total_build_times < circuit_build_times_min_circs_to_observe()) {
+ if (!circuit_build_times_enough_to_compute(cbt))
return 0;
- }
if (!circuit_build_times_update_alpha(cbt))
return 0;
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index 7cc5c2877..9d666ecc7 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -79,6 +79,7 @@ void bridges_retry_all(void);
void entry_guards_free_all(void);
extern circuit_build_times_t circ_times;
+int circuit_build_times_enough_to_compute(circuit_build_times_t *cbt);
void circuit_build_times_update_state(circuit_build_times_t *cbt,
or_state_t *state);
int circuit_build_times_parse_state(circuit_build_times_t *cbt,
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 6ecb92523..66ee0c435 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -278,8 +278,9 @@ void
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 */
+ /* circ_times.timeout_ms and circ_times.close_ms are from
+ * circuit_build_times_get_initial_timeout() if we haven't computed
+ * custom timeouts yet */
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);
diff --git a/src/or/or.h b/src/or/or.h
index dc4668413..c90b0391a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2979,8 +2979,9 @@ typedef uint32_t build_time_t;
* Maximum count of timeouts that finish the first hop in the past
* RECENT_CIRCUITS before calculating a new timeout.
*
- * This tells us to abandon timeout history and set
- * the timeout back to BUILD_TIMEOUT_INITIAL_VALUE.
+ * This tells us whether to abandon timeout history and set
+ * the timeout back to whatever circuit_build_times_get_initial_timeout()
+ * gives us.
*/
#define CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT (CBT_DEFAULT_RECENT_CIRCUITS*9/10)