diff options
author | David Goulet <dgoulet@torproject.org> | 2017-08-30 09:15:54 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-08-30 09:15:54 -0400 |
commit | 22295759afa90f19b06e2b657ce84d518c2390fd (patch) | |
tree | 87ab2f6eeca8091e4c775c031910863b918077b3 /src/or/hs_cache.c | |
parent | 209bfe715cc8c1c59b2578c406749a0d4a5bd8cb (diff) | |
download | tor-22295759afa90f19b06e2b657ce84d518c2390fd.tar.gz tor-22295759afa90f19b06e2b657ce84d518c2390fd.zip |
prop224: Purge client state on NEWNYM
Closes #23355
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cache.c')
-rw-r--r-- | src/or/hs_cache.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c index 6962c5ce44..78e2adacf6 100644 --- a/src/or/hs_cache.c +++ b/src/or/hs_cache.c @@ -726,6 +726,23 @@ hs_cache_clean_as_client(time_t now) cache_clean_v3_as_client(now); } +/* Purge the client descriptor cache. */ +void +hs_cache_purge_as_client(void) +{ + DIGEST256MAP_FOREACH_MODIFY(hs_cache_v3_client, key, + hs_cache_client_descriptor_t *, entry) { + size_t entry_size = cache_get_client_entry_size(entry); + MAP_DEL_CURRENT(key); + cache_client_desc_free(entry); + /* Update our OOM. We didn't use the remove() function because we are in + * a loop so we have to explicitely decrement. */ + rend_cache_decrement_allocation(entry_size); + } DIGEST256MAP_FOREACH_END; + + log_info(LD_REND, "Hidden service client descriptor cache purged."); +} + /* For a given service identity public key and an introduction authentication * key, note the given failure in the client intro state cache. */ void @@ -779,6 +796,20 @@ hs_cache_client_intro_state_clean(time_t now) } DIGEST256MAP_FOREACH_END; } +/* Purge the client introduction state cache. */ +void +hs_cache_client_intro_state_purge(void) +{ + DIGEST256MAP_FOREACH_MODIFY(hs_cache_client_intro_state, key, + hs_cache_client_intro_state_t *, cache) { + MAP_DEL_CURRENT(key); + cache_client_intro_state_free(cache); + } DIGEST256MAP_FOREACH_END; + + log_info(LD_REND, "Hidden service client introduction point state " + "cache purged."); +} + /**************** Generics *********************************/ /* Do a round of OOM cleanup on all directory caches. Return the amount of |