prop224: Purge client state on NEWNYM

Closes #23355

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet
2017-08-30 09:15:54 -04:00
parent 209bfe715c
commit 22295759af
8 changed files with 100 additions and 7 deletions
+31
View File
@@ -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