[or-cvs] r14793: Backport fix for bug noted by roger: rebuild extrainfo store (in tor/branches/tor-0_2_0-patches: . src/or)

nickm at seul.org nickm at seul.org
Thu May 29 00:45:07 UTC 2008


Author: nickm
Date: 2008-05-28 20:45:07 -0400 (Wed, 28 May 2008)
New Revision: 14793

Modified:
   tor/branches/tor-0_2_0-patches/ChangeLog
   tor/branches/tor-0_2_0-patches/src/or/routerlist.c
Log:
Backport fix for bug noted by roger: rebuild extrainfo store from time to time, even if we have never actually downloaded an extrainfo.  Bridge authorities need this, or they never clean the extrainfo store.

Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog	2008-05-29 00:44:57 UTC (rev 14792)
+++ tor/branches/tor-0_2_0-patches/ChangeLog	2008-05-29 00:45:07 UTC (rev 14793)
@@ -17,6 +17,10 @@
     - Allow comments in geoip file.
     - Make bridge authorities never serve extrainfo docs.
 
+  o Minor bugfixes:
+    - Make bridge authorities correctly clean extrainfo store from time to
+      time.
+
   o New files:
     - A new contrib/tor-exit-notice.html file that exit relay operators
       can put on their website to help reduce abuse queries.

Modified: tor/branches/tor-0_2_0-patches/src/or/routerlist.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/routerlist.c	2008-05-29 00:44:57 UTC (rev 14792)
+++ tor/branches/tor-0_2_0-patches/src/or/routerlist.c	2008-05-29 00:45:07 UTC (rev 14793)
@@ -559,15 +559,18 @@
   return (int)(r1->published_on - r2->published_on);
 }
 
-/** If the journal is too long, or if <b>force</b> is true, then atomically
- * replace the router store with the routers currently in our routerlist, and
- * clear the journal.  Return 0 on success, -1 on failure.
+#define RRS_FORCE 1
+#define RRS_DONT_REMOVE_OLD 2
+
+/** If the journal is too long, or if RRS_FORCE is set in <b>flags</b>, then
+ * atomically replace the router store with the routers currently in our
+ * routerlist, and clear the journal.  Return 0 on success, -1 on failure.
  *
  * If <b>extrainfo</b> is true, rebuild the extrainfo store; else rebuild the
  * router descriptor store.
  */
 static int
-router_rebuild_store(int force, desc_store_t *store)
+router_rebuild_store(int flags, desc_store_t *store)
 {
   smartlist_t *chunk_list = NULL;
   char *fname = NULL, *fname_tmp = NULL;
@@ -577,6 +580,7 @@
   int nocache=0;
   size_t total_expected_len = 0;
   int had_any;
+  int force = flags & RRS_FORCE;
 
   if (!force && !router_should_rebuild_store(store))
     return 0;
@@ -590,7 +594,8 @@
                smartlist_len(routerlist->old_routers))>0;
 
   /* Don't save deadweight. */
-  routerlist_remove_old_routers();
+  if (!(flags & RRS_DONT_REMOVE_OLD))
+    routerlist_remove_old_routers();
 
   log_info(LD_DIR, "Rebuilding %s cache", store->description);
 
@@ -781,7 +786,7 @@
 
   if (store->journal_len || read_from_old_location) {
     /* Always clear the journal on startup.*/
-    router_rebuild_store(1, store);
+    router_rebuild_store(RRS_FORCE, store);
   } else if (!extrainfo) {
     /* Don't cache expired routers. (This is in an else because
      * router_rebuild_store() also calls remove_old_routers().) */
@@ -3142,6 +3147,8 @@
 
  done:
   digestmap_free(retain, NULL);
+  router_rebuild_store(RRS_DONT_REMOVE_OLD, &routerlist->desc_store);
+  router_rebuild_store(RRS_DONT_REMOVE_OLD,&routerlist->extrainfo_store);
 }
 
 /** We just added a new set of descriptors. Take whatever extra steps



More information about the tor-commits mailing list