[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [tor/master 18/28] Make the Xm mode selection a consensus parameter.
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Mon, 7 Jun 2010 21:17:12 -0700
Subject: Make the Xm mode selection a consensus parameter.
Commit: f897154b26ffddf42f8c9b1988dbcb4355222c37
---
src/or/circuitbuild.c | 16 +++++++++++++---
src/or/or.h | 2 +-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index f16c8b6..7dc544d 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -116,6 +116,14 @@ circuit_build_times_max_timeouts(void)
}
static int32_t
+circuit_build_times_default_num_xm_modes(void)
+{
+ int32_t num = networkstatus_get_param(NULL, "cbtnummodes",
+ CBT_DEFAULT_NUM_XM_MODES);
+ return num;
+}
+
+static int32_t
circuit_build_times_min_circs_to_observe(void)
{
int32_t num = networkstatus_get_param(NULL, "cbtmincircs",
@@ -410,19 +418,20 @@ static build_time_t
circuit_build_times_get_xm(circuit_build_times_t *cbt)
{
build_time_t i, nbins;
- build_time_t nth_max_bin[CBT_NUM_XM_MODES];
+ build_time_t *nth_max_bin;
int32_t bin_counts=0;
build_time_t ret = 0;
uint32_t *histogram = circuit_build_times_create_histogram(cbt, &nbins);
int n=0;
- int num_modes = CBT_NUM_XM_MODES;
+ int num_modes = circuit_build_times_default_num_xm_modes();
// Only use one mode if < 1000 buildtimes. Not enough data
// for multiple.
if (cbt->total_build_times < CBT_NCIRCUITS_TO_OBSERVE)
num_modes = 1;
- memset(nth_max_bin, 0, sizeof(nth_max_bin));
+ nth_max_bin = (build_time_t*)tor_malloc_zero(num_modes*sizeof(build_time_t));
+
for (i = 0; i < nbins; i++) {
if (histogram[i] >= histogram[nth_max_bin[0]]) {
nth_max_bin[0] = i;
@@ -446,6 +455,7 @@ circuit_build_times_get_xm(circuit_build_times_t *cbt)
ret /= bin_counts;
tor_free(histogram);
+ tor_free(nth_max_bin);
return ret;
}
diff --git a/src/or/or.h b/src/or/or.h
index 49abf55..e99b2e9 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3023,7 +3023,7 @@ void entry_guards_free_all(void);
#define CBT_BIN_WIDTH ((build_time_t)50)
/** Number of modes to use in the weighted-avg computation of Xm */
-#define CBT_NUM_XM_MODES 3
+#define CBT_DEFAULT_NUM_XM_MODES 3
/** A build_time_t is milliseconds */
typedef uint32_t build_time_t;
--
1.7.1