[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r9649: the other half of r9572, suggested by seeess: when we receiv (tor/trunk/src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r9649: the other half of r9572, suggested by seeess: when we receiv (tor/trunk/src/or)
- From: arma@xxxxxxxx
- Date: Sat, 24 Feb 2007 22:43:00 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sat, 24 Feb 2007 22:43:09 -0500
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: arma
Date: 2007-02-24 22:43:00 -0500 (Sat, 24 Feb 2007)
New Revision: 9649
Modified:
tor/trunk/src/or/dirserv.c
Log:
the other half of r9572, suggested by seeess: when we receive
a v1 dir or rr that is too old, don't even cache it.
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2007-02-24 23:55:36 UTC (rev 9648)
+++ tor/trunk/src/or/dirserv.c 2007-02-25 03:43:00 UTC (rev 9649)
@@ -21,6 +21,11 @@
* directory authorities. */
#define MAX_UNTRUSTED_NETWORKSTATUSES 16
+/** If a v1 directory is older than this, discard it. */
+#define MAX_V1_DIRECTORY_AGE (30*24*60*60)
+/** If a v1 running-routers is older than this, discard it. */
+#define MAX_V1_RR_AGE (7*24*60*60)
+
/** Do we need to regenerate the directory when someone asks for it? */
static int the_directory_is_dirty = 1;
static int runningrouters_is_dirty = 1;
@@ -1031,6 +1036,8 @@
/** If we have no cached directory, or it is older than <b>published</b>,
* then replace it with <b>directory</b>, published at <b>published</b>.
*
+ * If <b>published</b> is too old, do nothing.
+ *
* If <b>is_running_routers</b>, this is really a running_routers document
* rather than a v1 directory.
*/
@@ -1038,11 +1045,16 @@
dirserv_set_cached_directory(const char *directory, time_t published,
int is_running_routers)
{
+ time_t now = time(NULL);
+
if (is_running_routers) {
- set_cached_dir(&cached_runningrouters, tor_strdup(directory), published);
+ if (published >= now - MAX_V1_RR_AGE)
+ set_cached_dir(&cached_runningrouters, tor_strdup(directory), published);
} else {
- cached_dir_decref(cached_directory);
- cached_directory = new_cached_dir(tor_strdup(directory), published);
+ if (published >= now - MAX_V1_DIRECTORY_AGE) {
+ cached_dir_decref(cached_directory);
+ cached_directory = new_cached_dir(tor_strdup(directory), published);
+ }
}
}
@@ -1148,8 +1160,6 @@
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);