summaryrefslogtreecommitdiff
path: root/src/or/rendcache.c
diff options
context:
space:
mode:
authorDonncha O'Cearbhaill <donncha@donncha.is>2015-08-25 16:35:35 +0200
committerDonncha O'Cearbhaill <donncha@donncha.is>2015-09-08 12:34:05 +0200
commit335d0b95d36bada44e720b365f6482ce8f54c1d7 (patch)
treee78cdfadbf0bcfdff8733d351994728e71649e61 /src/or/rendcache.c
parentee1a4ce8b2d927dff5e8feafe8b0363d57a4f32e (diff)
downloadtor-335d0b95d36bada44e720b365f6482ce8f54c1d7.tar.gz
tor-335d0b95d36bada44e720b365f6482ce8f54c1d7.zip
Clean old descriptors from the service-side rend cache
Parameterize the rend_cache_clean() function to allow it clean old rendezvous descriptors from the service-side cache as well as the client descriptor cache.
Diffstat (limited to 'src/or/rendcache.c')
-rw-r--r--src/or/rendcache.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index aae37ebbf7..09f435ca8e 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -260,24 +260,33 @@ rend_cache_failure_clean(time_t now)
} STRMAP_FOREACH_END;
}
-/** Removes all old entries from the service descriptor cache.
+/** Removes all old entries from the client or service descriptor cache.
*/
void
-rend_cache_clean(time_t now)
+rend_cache_clean(time_t now, rend_cache_type_t cache_type)
{
strmap_iter_t *iter;
const char *key;
void *val;
rend_cache_entry_t *ent;
time_t cutoff = now - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
- for (iter = strmap_iter_init(rend_cache); !strmap_iter_done(iter); ) {
+ strmap_t *cache = NULL;
+
+ if (cache_type == REND_CACHE_TYPE_CLIENT) {
+ cache = rend_cache;
+ } else if (cache_type == REND_CACHE_TYPE_SERVICE) {
+ cache = rend_cache_service;
+ }
+ tor_assert(cache);
+
+ for (iter = strmap_iter_init(cache); !strmap_iter_done(iter); ) {
strmap_iter_get(iter, &key, &val);
ent = (rend_cache_entry_t*)val;
if (ent->parsed->timestamp < cutoff) {
- iter = strmap_iter_next_rmv(rend_cache, iter);
+ iter = strmap_iter_next_rmv(cache, iter);
rend_cache_entry_free(ent);
} else {
- iter = strmap_iter_next(rend_cache, iter);
+ iter = strmap_iter_next(cache, iter);
}
}
}