diff options
author | Roger Dingledine <arma@torproject.org> | 2007-06-15 04:20:51 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2007-06-15 04:20:51 +0000 |
commit | 73f7310d9b7fdca11278b139336a0671be1ee883 (patch) | |
tree | aad52d6f60b448fca11806098e80e36e9e509aeb /src/or/dirserv.c | |
parent | cfc6b4e0749fc517e42b20394bdbf5f49a419294 (diff) | |
download | tor-73f7310d9b7fdca11278b139336a0671be1ee883.tar.gz tor-73f7310d9b7fdca11278b139336a0671be1ee883.zip |
Directories no longer return a "304 not modified" when they don't
have the networkstatus the client asked for. Also fix a memory
leak when returning 304 not modified. [Bugfixes on 0.2.0.2-alpha]
svn:r10607
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r-- | src/or/dirserv.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 69f73b99f7..4d4b6902f7 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2538,29 +2538,31 @@ 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>. */ +/** Remove from <b>fps</b> every networkstatus key where both + * a) we have a networkstatus document and + * b) it is not newer than <b>cutoff</b>. + * + * Return 1 if no keys remain, else return 0. + */ int dirserv_statuses_are_old(smartlist_t *fps, time_t cutoff) { - SMARTLIST_FOREACH(fps, const char *, digest, + SMARTLIST_FOREACH(fps, 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; - /* XXX020 The above is causing my dir cache to send "304 Not modified" - * to clients that never specified an If-Modified-Since header. That's - * because d isn't defined for the networkstatus the client is asking - * for, so we end up returning 1. Perhaps the right fix above is - * "if (!d || d->published >= cutoff)"? -RD - */ + if (d && d->published <= cutoff) { + tor_free(digest); + SMARTLIST_DEL_CURRENT(fps, digest); + } }); - return 1; + if (smartlist_len(fps)) + return 0; /* some items were not here or were not old */ + return 1; /* all items were here and old */ } /** Return an approximate estimate of the number of bytes that will |