diff options
-rw-r--r-- | src/or/config.c | 11 | ||||
-rw-r--r-- | src/or/main.c | 19 | ||||
-rw-r--r-- | src/or/rephist.c | 6 | ||||
-rw-r--r-- | src/or/router.c | 5 |
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. |