mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 10:12:15 +01:00
r14729@catbus: nickm | 2007-08-20 11:58:02 -0400
Trigger load and save of MTBF data. svn:r11219
This commit is contained in:
parent
d3b019a1df
commit
9958dc8d53
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user