[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17917: {tor} If the cached networkstatus consensus is more than five days (in tor/trunk: . src/or)



Author: arma
Date: 2009-01-05 11:56:11 -0500 (Mon, 05 Jan 2009)
New Revision: 17917

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/networkstatus.c
   tor/trunk/src/or/or.h
Log:
If the cached networkstatus consensus is more than five days old,
discard it rather than trying to use it. In theory it could
be useful because it lists alternate directory mirrors, but in
practice it just means we spend many minutes trying directory
mirrors that are long gone from the network. Helps bug 887 a bit;
bugfix on 0.2.0.x.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2009-01-05 16:55:08 UTC (rev 17916)
+++ tor/trunk/ChangeLog	2009-01-05 16:56:11 UTC (rev 17917)
@@ -1,4 +1,12 @@
 Changes in version 0.2.1.10-alpha - 2009-01-??
+  o Major bugfixes:
+    - If the cached networkstatus consensus is more than five days old,
+      discard it rather than trying to use it. In theory it could
+      be useful because it lists alternate directory mirrors, but in
+      practice it just means we spend many minutes trying directory
+      mirrors that are long gone from the network. Helps bug 887 a bit;
+      bugfix on 0.2.0.x.
+
   o Minor features:
     - New controller event "clients_seen" to report a geoip-based summary
       of which countries we've seen clients from recently. Now controllers

Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c	2009-01-05 16:55:08 UTC (rev 17916)
+++ tor/trunk/src/or/networkstatus.c	2009-01-05 16:56:11 UTC (rev 17917)
@@ -211,7 +211,8 @@
     s = read_file_to_str(options->FallbackNetworkstatusFile,
                          RFTS_IGNORE_MISSING, NULL);
     if (s) {
-      if (networkstatus_set_current_consensus(s, flags)) {
+      if (networkstatus_set_current_consensus(s,
+                                              flags|NSSET_ACCEPT_OBSOLETE)) {
         log_info(LD_FS, "Couldn't load consensus networkstatus from \"%s\"",
                  options->FallbackNetworkstatusFile);
       } else {
@@ -1371,6 +1372,8 @@
  * cache.  If flags & NSSET_WAS_WAITING_FOR_CERTS, this networkstatus was
  * already received, but we were waiting for certificates on it.  If flags &
  * NSSET_DONT_DOWNLOAD_CERTS, do not launch certificate downloads as needed.
+ * If flags & NSSET_ACCEPT_OBSOLETE, then we should be willing to take this
+ * consensus, even if it comes from many days in the past.
  *
  * Return 0 on success, <0 on failure.  On failure, caller should increment
  * the failure count as appropriate.
@@ -1388,6 +1391,7 @@
   const unsigned from_cache = flags & NSSET_FROM_CACHE;
   const unsigned was_waiting_for_certs = flags & NSSET_WAS_WAITING_FOR_CERTS;
   const unsigned dl_certs = !(flags & NSSET_DONT_DOWNLOAD_CERTS);
+  const unsigned accept_obsolete = flags & NSSET_ACCEPT_OBSOLETE;
 
   /* Make sure it's parseable. */
   c = networkstatus_parse_vote_from_string(consensus, NULL, NS_TYPE_CONSENSUS);
@@ -1397,6 +1401,15 @@
     goto done;
   }
 
+  if (from_cache && !accept_obsolete &&
+      c->valid_until < now-OLD_ROUTER_DESC_MAX_AGE) {
+    /* XXX022 when we try to make fallbackconsensus work again, we should
+     * consider taking this out. Until then, believing obsolete consensuses
+     * is causing more harm than good. See also bug 887. */
+    log_info(LD_DIR, "Loaded an obsolete consensus. Discarding.");
+    goto done;
+  }
+
   if (current_consensus &&
       !memcmp(c->networkstatus_digest, current_consensus->networkstatus_digest,
               DIGEST_LEN)) {

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2009-01-05 16:55:08 UTC (rev 17916)
+++ tor/trunk/src/or/or.h	2009-01-05 16:56:11 UTC (rev 17917)
@@ -3758,6 +3758,7 @@
 #define NSSET_FROM_CACHE 1
 #define NSSET_WAS_WAITING_FOR_CERTS 2
 #define NSSET_DONT_DOWNLOAD_CERTS 4
+#define NSSET_ACCEPT_OBSOLETE 8
 int networkstatus_set_current_consensus(const char *consensus, unsigned flags);
 void networkstatus_note_certs_arrived(void);
 void routers_update_all_from_networkstatus(time_t now, int dir_version);