summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2009-09-15 18:00:48 -0700
committerMike Perry <mikeperry-git@fscked.org>2009-09-16 17:20:29 -0700
commit5bd60d8a411c90000e6a55e70eb814ea6c69e011 (patch)
treeb3ba5ffe439d68d33926ec113bc712eab45b5f4c
parent81dc435ffaa86382c7702a5d7c7460635225dcb7 (diff)
downloadtor-5bd60d8a411c90000e6a55e70eb814ea6c69e011.tar.gz
tor-5bd60d8a411c90000e6a55e70eb814ea6c69e011.zip
Address nickm's issues from his review #1.
-rw-r--r--src/or/circuitbuild.c14
-rw-r--r--src/or/or.h14
2 files changed, 22 insertions, 6 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index a141795a1e..25b81992b9 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -88,7 +88,7 @@ static smartlist_t *entry_guards = NULL;
static int entry_guards_dirty = 0;
/** If set, we're running the unit tests: we should avoid clobbering
- * our state file. */
+ * our state file or accessing get_options() or get_or_state() */
static int unit_tests = 0;
/********* END VARIABLES ************/
@@ -427,11 +427,15 @@ circuit_build_times_update_alpha(circuit_build_times_t *cbt)
cbt->Xm = circuit_build_times_mode(cbt);
for (i=0; i< NCIRCUITS_TO_OBSERVE; i++) {
- if (!x[i]) continue;
+ if (!x[i]) {
+ continue;
+ }
- // Hrmm, should we count < Xm as Xm or just drop
- if (x[i] < cbt->Xm) a += ln(cbt->Xm);
- else a += ln(x[i]);
+ if (x[i] < cbt->Xm) {
+ a += ln(cbt->Xm);
+ } else {
+ a += ln(x[i]);
+ }
n++;
}
diff --git a/src/or/or.h b/src/or/or.h
index 4ee5abf21d..a343b1f4b1 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2875,12 +2875,13 @@ void entry_guards_free_all(void);
#define NCIRCUITS_TO_OBSERVE 5000
/** Width of the histogram bins in milliseconds */
-#define BUILDTIME_BIN_WIDTH 50
+#define BUILDTIME_BIN_WIDTH ((build_time_t)50)
/** Cuttof point on the CDF for our timeout estimation.
* TODO: This should be moved to the consensus */
#define BUILDTIMEOUT_QUANTILE_CUTOFF 0.8
+/** A build_time_t is milliseconds */
typedef uint32_t build_time_t;
#define BUILD_TIME_MAX ((build_time_t)(INT32_MAX))
@@ -2900,15 +2901,26 @@ typedef uint32_t build_time_t;
#define BUILD_TIMES_SAVE_STATE_EVERY 10
typedef struct {
+ /** The circular array of recorded build times in milliseconds */
build_time_t circuit_build_times[NCIRCUITS_TO_OBSERVE];
+ /** The timestamp we last completed a TLS handshake or received a cell */
time_t network_last_live;
+ /** Last time we built a circuit. Used to decide to build new test circs */
time_t last_circ_at;
+ /** Current index in the circuit_build_times circular array */
int build_times_idx;
+ /** Total number of build times accumulated. Maxes at NCIRCUITS_TO_OBSERVE */
int total_build_times;
+ /** Number of timeouts that have happened before estimating pareto
+ * parameters */
int pre_timeouts;
+ /** "Minimum" value of our pareto distribution (actually mode) */
build_time_t Xm;
+ /** alpha exponent for pareto dis */
double alpha;
+ /** Have we computed a timeout? */
int have_computed_timeout;
+ /** The value for that timeout in seconds, not milliseconds */
int timeout;
} circuit_build_times_t;