summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-08-20 15:59:31 +0000
committerNick Mathewson <nickm@torproject.org>2007-08-20 15:59:31 +0000
commit9958dc8d5375b88cb6d07b168ff09a8d76acaa8e (patch)
treed8ccec6f38be2abb5f61dbe0b0f3e4439db2e826
parentd3b019a1df1b821cf4634ee289ec3d47d74c9a2a (diff)
downloadtor-9958dc8d5375b88cb6d07b168ff09a8d76acaa8e.tar.gz
tor-9958dc8d5375b88cb6d07b168ff09a8d76acaa8e.zip
r14729@catbus: nickm | 2007-08-20 11:58:02 -0400
Trigger load and save of MTBF data. svn:r11219
-rw-r--r--src/or/config.c11
-rw-r--r--src/or/main.c19
-rw-r--r--src/or/rephist.c6
-rw-r--r--src/or/router.c5
4 files changed, 39 insertions, 2 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 048266f456..2dc3b973f1 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1001,10 +1001,19 @@ options_act(or_options_t *old_options)
}
/* Load state */
- if (! global_state)
+ if (! global_state) {
if (or_state_load())
return -1;
+ /* XXXX020 make this conditional? */
+ len = strlen(options->DataDirectory)+32;
+ fn = tor_malloc(len);
+ tor_snprintf(fn, len, "%s"PATH_SEPARATOR"router-stability",
+ options->DataDirectory);
+ rep_hist_load_mtbf_data(fn, time(NULL));
+ tor_free(fn);
+ }
+
/* Bail out at this point if we're not going to be a client or server:
* we want to not fork, and to log stuff to stderr. */
if (options->command != CMD_RUN_TOR)
diff --git a/src/or/main.c b/src/or/main.c
index aae07dfcf5..d97c74450a 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -845,6 +845,9 @@ run_scheduled_events(time_t now)
static time_t time_to_add_entropy = 0;
static time_t time_to_write_hs_statistics = 0;
static time_t time_to_downrate_stability = 0;
+ /* XXXX020 this is way too low. */
+#define SAVE_STABILITY_INTERVAL (10*60)
+ static time_t time_to_save_stability = 0;
or_options_t *options = get_options();
int i;
int have_dir_info;
@@ -935,6 +938,22 @@ run_scheduled_events(time_t now)
/** 1d. DOCDOC */
if (time_to_downrate_stability < now)
time_to_downrate_stability = rep_hist_downrate_old_runs(now);
+ if (authdir_mode_tests_reachability(options)) {
+ if (!time_to_save_stability)
+ time_to_save_stability = now + SAVE_STABILITY_INTERVAL;
+ if (time_to_save_stability < now) {
+ size_t len = strlen(options->DataDirectory)+32;
+ char *fn = tor_malloc(len);
+ tor_snprintf(fn, len, "%s"PATH_SEPARATOR"router-stability",
+ options->DataDirectory);
+ if (rep_hist_record_mtbf_data(fn)<0) {
+ log_warn(LD_GENERAL, "Couldn't store mtbf data in %s", fn);
+ }
+ tor_free(fn);
+
+ time_to_save_stability = now + SAVE_STABILITY_INTERVAL;
+ }
+ }
/** 2. Periodically, we consider getting a new directory, getting a
* new running-routers list, and/or force-uploading our descriptor
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 3228d24a3f..a74a28315e 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -519,11 +519,17 @@ rep_hist_record_mtbf_data(const char *filename)
smartlist_add(lines, tor_strdup("format 1\n"));
+ format_iso_time(time_buf, time(NULL));
+ tor_snprintf(buf, sizeof(buf), "stored-at %s\n", time_buf);
+ smartlist_add(lines, tor_strdup(buf));
+
if (stability_last_downrated) {
format_iso_time(time_buf, stability_last_downrated);
tor_snprintf(buf, sizeof(buf), "last-downrated %s\n", time_buf);
smartlist_add(lines, tor_strdup(buf));
}
+
+
smartlist_add(lines, tor_strdup("data\n"));
for (orhist_it = digestmap_iter_init(history_map);
diff --git a/src/or/router.c b/src/or/router.c
index 57942fb93f..dc44ad48fc 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -752,7 +752,10 @@ authdir_mode_publishes_statuses(or_options_t *options)
{
if (authdir_mode_bridge(options))
return 0;
- return authdir_mode_v1(options) || authdir_mode_v2(options);
+ return authdir_mode(options) &&
+ (options->V1AuthoritativeDir ||
+ options->V2AuthoritativeDir ||
+ options->V3AuthoritativeDir);
}
/** Return true iff we are an authoritative directory server that
* tests reachability of the descriptors it learns about.