[or-cvs] r11219: Trigger load and save of MTBF data. (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Mon Aug 20 15:59:32 UTC 2007


Author: nickm
Date: 2007-08-20 11:59:31 -0400 (Mon, 20 Aug 2007)
New Revision: 11219

Modified:
   tor/trunk/
   tor/trunk/src/or/config.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/rephist.c
   tor/trunk/src/or/router.c
Log:
 r14729 at catbus:  nickm | 2007-08-20 11:58:02 -0400
 Trigger load and save of MTBF data.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r14729] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2007-08-20 15:43:17 UTC (rev 11218)
+++ tor/trunk/src/or/config.c	2007-08-20 15:59:31 UTC (rev 11219)
@@ -1001,10 +1001,19 @@
   }
 
   /* 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)

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-08-20 15:43:17 UTC (rev 11218)
+++ tor/trunk/src/or/main.c	2007-08-20 15:59:31 UTC (rev 11219)
@@ -845,6 +845,9 @@
   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,7 +938,23 @@
   /** 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
    * (if we've passed our internal checks). */

Modified: tor/trunk/src/or/rephist.c
===================================================================
--- tor/trunk/src/or/rephist.c	2007-08-20 15:43:17 UTC (rev 11218)
+++ tor/trunk/src/or/rephist.c	2007-08-20 15:59:31 UTC (rev 11219)
@@ -519,11 +519,17 @@
 
   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);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-08-20 15:43:17 UTC (rev 11218)
+++ tor/trunk/src/or/router.c	2007-08-20 15:59:31 UTC (rev 11219)
@@ -752,7 +752,10 @@
 {
   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.



More information about the tor-commits mailing list