aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendcache.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-08-05 14:06:09 -0400
committerNick Mathewson <nickm@torproject.org>2015-08-11 09:34:41 -0400
commit7dce409802193eed9f8378e11b1c38eeb1127929 (patch)
tree50a375299fd16cd22488bce6e256c4c1edcee2e4 /src/or/rendcache.c
parent6e967235240dede017bbf0a696de62443fd2a7c3 (diff)
downloadtor-7dce409802193eed9f8378e11b1c38eeb1127929.tar.gz
tor-7dce409802193eed9f8378e11b1c38eeb1127929.zip
Expire after 5 minutes rend cache failure entries
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/rendcache.c')
-rw-r--r--src/or/rendcache.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index 9be9e24941..9a33046fb6 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -225,6 +225,35 @@ rend_cache_free_all(void)
rend_cache_total_allocation = 0;
}
+/** Remove all entries that re REND_CACHE_FAILURE_MAX_AGE old. This is
+ * called every second.
+ *
+ * We have to clean these regurlarly else if for whatever reasons an hidden
+ * service goes offline and a client tries to connect to it during that
+ * time, a failure entry is created and the client will be unable to connect
+ * for a while even though the service has return online. */
+void
+rend_cache_failure_clean(time_t now)
+{
+ time_t cutoff = now - REND_CACHE_FAILURE_MAX_AGE;
+ STRMAP_FOREACH_MODIFY(rend_cache_failure, key,
+ rend_cache_failure_t *, ent) {
+ /* Free and remove every intro failure object that match the cutoff. */
+ DIGESTMAP_FOREACH_MODIFY(ent->intro_failures, ip_key,
+ rend_cache_failure_intro_t *, ip_ent) {
+ if (ip_ent->created_ts < cutoff) {
+ rend_cache_failure_intro_entry_free(ip_ent);
+ MAP_DEL_CURRENT(ip_key);
+ }
+ } DIGESTMAP_FOREACH_END;
+ /* If the entry is now empty of intro point failures, remove it. */
+ if (digestmap_isempty(ent->intro_failures)) {
+ rend_cache_failure_entry_free(ent);
+ MAP_DEL_CURRENT(key);
+ }
+ } STRMAP_FOREACH_END;
+}
+
/** Removes all old entries from the service descriptor cache.
*/
void