[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Clean old descriptors from the service-side rend cache
commit 335d0b95d36bada44e720b365f6482ce8f54c1d7
Author: Donncha O'Cearbhaill <donncha@xxxxxxxxxx>
Date: Tue Aug 25 16:35:35 2015 +0200
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.
---
src/or/main.c | 3 ++-
src/or/rendcache.c | 19 ++++++++++++++-----
src/or/rendcache.h | 2 +-
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/or/main.c b/src/or/main.c
index 0b0207b..9e79858 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1518,7 +1518,8 @@ run_scheduled_events(time_t now)
/* Remove old information from rephist and the rend cache. */
if (time_to.clean_caches < now) {
rep_history_clean(now - options->RephistTrackTime);
- rend_cache_clean(now);
+ rend_cache_clean(now, REND_CACHE_TYPE_CLIENT);
+ rend_cache_clean(now, REND_CACHE_TYPE_SERVICE);
rend_cache_clean_v2_descs_as_dir(now, 0);
microdesc_cache_rebuild(NULL, 0);
#define CLEAN_CACHES_INTERVAL (30*60)
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index aae37eb..09f435c 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);
}
}
}
diff --git a/src/or/rendcache.h b/src/or/rendcache.h
index e13c9b4..f04d087 100644
--- a/src/or/rendcache.h
+++ b/src/or/rendcache.h
@@ -54,7 +54,7 @@ typedef enum {
} rend_cache_type_t;
void rend_cache_init(void);
-void rend_cache_clean(time_t now);
+void rend_cache_clean(time_t now, rend_cache_type_t cache_type);
void rend_cache_failure_clean(time_t now);
void rend_cache_clean_v2_descs_as_dir(time_t now, size_t min_to_remove);
void rend_cache_purge(void);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits