[or-cvs] r9572: Discard any v1 directory info that is so old as to be useles (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Mon Feb 12 23:39:30 UTC 2007


Author: nickm
Date: 2007-02-12 18:39:24 -0500 (Mon, 12 Feb 2007)
New Revision: 9572

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
 r11781 at catbus:  nickm | 2007-02-12 18:31:33 -0500
 Discard any v1 directory info that is so old as to be useless.  (Fixes bug 387)



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

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-12 21:52:32 UTC (rev 9571)
+++ tor/trunk/ChangeLog	2007-02-12 23:39:24 UTC (rev 9572)
@@ -6,6 +6,9 @@
   o Major bugfixes (crashes):
     - Stop crashing when the controller asks us to resetconf more than
       one config option at once. (Vidalia 0.0.11 does this.)
+    - Fix a crash that happened on Win98 when we're given command-line
+      arguments: Don't try to load NT service functions from advapi32.dll
+      except when we need them. (bug introduced in 0.1.2.7-alpha).
 
   o Minor bugfixes (controller):
     - Give the controller END_STREAM_REASON_DESTROY events _before_ we
@@ -31,8 +34,6 @@
       other than file-not-found.
     - Don't warn the user when cached-routers.new doesn't exist: that's
       perfectly fine when starting up for the first time.
-    - Don't try to load NT service functions from advapi32.dll except when
-      we need them. (bug introduced in 0.1.2.7-alpha).
 
   o Minor features:
     - Warn the user when an application uses the obsolete binary v0
@@ -49,6 +50,8 @@
       protocol easier to recognize on the wire.)
     - Revise messages on handshake failure again to be even more clear about
       which are incoming connections and which are outgoing.
+    - Discard any v1 directory info that's over 1 month old (for
+      directories) or over 1 week old (for running-routers lists).
 
 
 Changes in version 0.1.2.7-alpha - 2007-02-06

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-02-12 21:52:32 UTC (rev 9571)
+++ tor/trunk/src/or/dirserv.c	2007-02-12 23:39:24 UTC (rev 9572)
@@ -937,10 +937,11 @@
   return -1;
 }
 
-/** Most recently generated encoded signed directory. (auth dirservers only.)*/
+/** Most recently generated encoded signed v1 directory. (auth dirservers
+ * only.)*/
 static cached_dir_t *the_directory = NULL;
 
-/* Used only by non-auth dirservers: The directory and runningrouters we'll
+/* Used only by non-auth dirservers: The v1 directory and runningrouters we'll
  * serve when requested. */
 static cached_dir_t *cached_directory = NULL;
 static cached_dir_t cached_runningrouters = { NULL, NULL, 0, 0, 0, -1 };
@@ -1135,7 +1136,22 @@
       iter = digestmap_iter_next(cached_v2_networkstatus, iter);
     }
   }
+}
 
+/** Remove any networkstatus from the directory cache that was published
+ * before <b>cutoff</b>. */
+void
+dirserv_clear_old_v1_info(time_t now)
+{
+#define MAX_V1_DIRECTORY_AGE (30*24*60*60)
+#define MAX_V1_RR_AGE (7*24*60*60)
+  if (cached_directory &&
+      cached_directory->published < (now-MAX_V1_DIRECTORY_AGE)) {
+    cached_dir_decref(cached_directory);
+  }
+  if (cached_runningrouters.published < (now - MAX_V1_RR_AGE)) {
+    clear_cached_dir(&cached_runningrouters);
+  }
 }
 
 /** Helper: If we're an authority for the right directory version (the

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-02-12 21:52:32 UTC (rev 9571)
+++ tor/trunk/src/or/or.h	2007-02-12 23:39:24 UTC (rev 9572)
@@ -2427,6 +2427,7 @@
                                          const char *identity,
                                          time_t published);
 void dirserv_clear_old_networkstatuses(time_t cutoff);
+void dirserv_clear_old_v1_info(time_t now);
 void dirserv_get_networkstatus_v2(smartlist_t *result, const char *key);
 void dirserv_get_networkstatus_v2_fingerprints(smartlist_t *result,
                                                const char *key);

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-02-12 21:52:32 UTC (rev 9571)
+++ tor/trunk/src/or/routerlist.c	2007-02-12 23:39:24 UTC (rev 9572)
@@ -2590,8 +2590,9 @@
   }
 
   /* And now go through the directory cache for any cached untrusted
-   * networkstatuses. */
+   * networkstatuses and other network info. */
   dirserv_clear_old_networkstatuses(now - MAX_NETWORKSTATUS_AGE);
+  dirserv_clear_old_v1_info(now);
 }
 
 /** Helper for bsearching a list of routerstatus_t pointers.*/



More information about the tor-commits mailing list