]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r17558@catbus: nickm | 2008-01-10 13:07:41 -0500
authorNick Mathewson <nickm@torproject.org>
Thu, 10 Jan 2008 18:08:42 +0000 (18:08 +0000)
committerNick Mathewson <nickm@torproject.org>
Thu, 10 Jan 2008 18:08:42 +0000 (18:08 +0000)
 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.)

svn:r13096

ChangeLog
doc/TODO
src/or/networkstatus.c

index ab5d209988b97aad47ac824aeecbc6c94339a969..81d9ea85622323dbb111eb27914a818719c6615c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,9 @@ Changes in version 0.2.0.16-alpha - 2008-01-??
       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
index 96ea0771da83c496c318acf5b89a21af1b227cb6..ac757062e712e39b3d615c067db328d5ff8c9680 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -25,7 +25,7 @@ R - let bridges set relaybandwidthrate as low as 5kb
 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 @@ R - bridge communities
       - 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.
index 67e34a778657eb309d450dac8a39c034b65a1a88..b406166023cb3c5dcfd1ec4465452a9db7176184 100644 (file)
@@ -122,15 +122,29 @@ router_reload_v2_networkstatus(void)
   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);
-  tor_free(filename);
-  if (!entries) /* dir doesn't exist */
+  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);
   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,