[or-cvs] r13096: If we do not serve v2 directory info, and our cached v2 netw (in tor/trunk: . doc src/or)

nickm at seul.org nickm at seul.org
Thu Jan 10 18:08:42 UTC 2008


Author: nickm
Date: 2008-01-10 13:08:42 -0500 (Thu, 10 Jan 2008)
New Revision: 13096

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/networkstatus.c
Log:
 r17558 at catbus:  nickm | 2008-01-10 13:07:41 -0500
 If we do not serve v2 directory info, and our cached v2 networkstatus files are very old, remove them.  If the directory is old, remove that too.  (We already did this for obsolete routers files.)



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

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-01-10 17:54:24 UTC (rev 13095)
+++ tor/trunk/ChangeLog	2008-01-10 18:08:42 UTC (rev 13096)
@@ -18,6 +18,9 @@
       responses _and_ send a body too), there are still servers out there
       that haven't upgraded.  Therefore, make clients parse such bodies
       when they receive them.
+    - When we're not serving v2 directory information, there is no reason
+      to actually keep any around.  Remove the obsolete files and directory
+      on startup if they are very old and we aren't going to serve them.
 
   o Minor performance improvements:
     - Reference-count and share copies of address policy entries; only

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2008-01-10 17:54:24 UTC (rev 13095)
+++ tor/trunk/doc/TODO	2008-01-10 18:08:42 UTC (rev 13096)
@@ -25,7 +25,7 @@
 RK- make it easier to set up a private tor network on your own computer
     is very hard.
     - FAQ entry which is wrong
-  - Make BEGIN_DIR mandatory for asking questions of bridge authorities?
+  o Make BEGIN_DIR mandatory for asking questions of bridge authorities?
     (but only for bridge descriptors. not for ordinary cache stuff.)
     o Implement connection_dir_is_encrypted().
     o set up a filter to not answer any bridge descriptors on a
@@ -50,9 +50,9 @@
       - be able to have bridges that aren't in your torrc
 
 Things we'd like to do in 0.2.0.x:
-N - if we notice a cached-status directory and we're not serving v2 dir
-    info and it's old enough, delete it. same with cached-routers*.
-    Nick says: don't we already do that?
+  o if we notice a cached-status directory and we're not serving v2 dir
+    info and it's old enough, delete it.
+     o same with cached-routers*.
 N - document the "3/4 and 7/8" business in the clients fetching consensus
     documents timeline.
 R   - then document the bridge user download timeline.

Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c	2008-01-10 17:54:24 UTC (rev 13095)
+++ tor/trunk/src/or/networkstatus.c	2008-01-10 18:08:42 UTC (rev 13096)
@@ -122,15 +122,29 @@
   struct stat st;
   char *s;
   char *filename = get_datadir_fname("cached-status");
+  int maybe_delete = !directory_caches_v2_dir_info(get_options());
+  time_t now = time(NULL);
   if (!networkstatus_v2_list)
     networkstatus_v2_list = smartlist_create();
 
   entries = tor_listdir(filename);
+  if (!entries) { /* dir doesn't exist */
+    tor_free(filename);
+    return 0;
+  } else if (!smartlist_len(entries) && maybe_delete) {
+    rmdir(filename);
+    tor_free(filename);
+    return 0;
+  }
   tor_free(filename);
-  if (!entries) /* dir doesn't exist */
-    return 0;
   SMARTLIST_FOREACH(entries, const char *, fn, {
       char buf[DIGEST_LEN];
+      if (maybe_delete) {
+        filename = get_datadir_fname2("cached-status", fn);
+        remove_file_if_very_old(filename, now);
+        tor_free(filename);
+        continue;
+      }
       if (strlen(fn) != HEX_DIGEST_LEN ||
           base16_decode(buf, sizeof(buf), fn, strlen(fn))) {
         log_info(LD_DIR,



More information about the tor-commits mailing list