aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-06-02 15:26:57 +0000
committerNick Mathewson <nickm@torproject.org>2007-06-02 15:26:57 +0000
commitaee7f016242c0fea9243be1c82a67b804bfb6792 (patch)
tree6e28814091a4325047b48c2d95131f21ef25a846 /src/or/dirserv.c
parent80954dcd2faefe477bd0a3b646ffd3dce3c56481 (diff)
downloadtor-aee7f016242c0fea9243be1c82a67b804bfb6792.tar
tor-aee7f016242c0fea9243be1c82a67b804bfb6792.tar.gz
r13154@catbus: nickm | 2007-06-02 11:26:44 -0400
Server-side support for If-Modified-Since in HTTP requsts for v1 stuff, and for network-status documents. svn:r10451
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 31d85a249..82a42af11 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1279,6 +1279,7 @@ dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
}
}
+#if 0
/** Helper: If we're authoritative and <b>auth_src</b> is set, use
* <b>auth_src</b>, otherwise use <b>cache_src</b>. If we're using
* <b>auth_src</b> and it's been <b>dirty</b> for at least
@@ -1313,6 +1314,7 @@ dirserv_get_obj(const char **out,
return 0;
}
}
+#endif
/** Return the most recently generated encoded signed v1 directory,
* generating a new one as necessary. If not a v1 authoritative directory
@@ -1418,10 +1420,10 @@ generate_runningrouters(void)
/** Set *<b>rr</b> to the most recently generated encoded signed
* running-routers list, generating a new one as necessary. Return the
* size of the directory on success, and 0 on failure. */
-size_t
-dirserv_get_runningrouters(const char **rr, int compress)
+cached_dir_t *
+dirserv_get_runningrouters(void)
{
- return dirserv_get_obj(rr, compress,
+ return dirserv_pick_cached_dir_obj(
&cached_runningrouters, &the_runningrouters,
runningrouters_is_dirty,
generate_runningrouters,
@@ -2247,6 +2249,25 @@ dirserv_test_reachability(int try_all)
ctr = (ctr + 1) % 128;
}
+/** Return true iff every networkstatus listed in <b>fps</b> is older
+ * than <b>cutoff</b>. */
+int
+dirserv_statuses_are_old(smartlist_t *fps, time_t cutoff)
+{
+ SMARTLIST_FOREACH(fps, const char *, digest,
+ {
+ cached_dir_t *d;
+ if (router_digest_is_me(digest) && the_v2_networkstatus)
+ d = the_v2_networkstatus;
+ else
+ d = digestmap_get(cached_v2_networkstatus, digest);
+ if (d && d->published > cutoff)
+ return 0;
+ });
+
+ return 1;
+}
+
/** Return an approximate estimate of the number of bytes that will
* be needed to transmit the server descriptors (if is_serverdescs --
* they can be either d/ or fp/ queries) or networkstatus objects (if