From 10d86f76150bbb4fd37a17cc6f8c307c766d532b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 10 Jan 2008 18:08:42 +0000 Subject: [PATCH] r17558@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.) svn:r13096 --- ChangeLog | 3 +++ doc/TODO | 8 ++++---- src/or/networkstatus.c | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab5d209988..81d9ea8562 100644 --- 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 diff --git a/doc/TODO b/doc/TODO index 96ea0771da..ac757062e7 100644 --- 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. diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 67e34a7786..b406166023 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -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,