summaryrefslogtreecommitdiff
path: root/src/or/hs_cache.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-08-22 11:27:47 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-08-24 13:03:28 -0400
commit68887fdc5d4ff94cb8e88480e160349007d8a6a5 (patch)
tree8245e39b52dcaf447248c626f975637b5d8c9716 /src/or/hs_cache.c
parent47672ec1c7202feb0422317b39f9bcefb231fe5b (diff)
downloadtor-68887fdc5d4ff94cb8e88480e160349007d8a6a5.tar.gz
tor-68887fdc5d4ff94cb8e88480e160349007d8a6a5.zip
prop224: Update OOM counters when freeing a client descriptor cache object
When we free a client descriptor cache object, tell the OOM handler. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cache.c')
-rw-r--r--src/or/hs_cache.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c
index 28cb4d1bd9..e0d89a70e1 100644
--- a/src/or/hs_cache.c
+++ b/src/or/hs_cache.c
@@ -335,6 +335,8 @@ remove_v3_desc_as_client(const hs_cache_client_descriptor_t *desc)
{
tor_assert(desc);
digest256map_remove(hs_cache_v3_client, desc->key.pubkey);
+ /* Update cache size with this entry for the OOM handler. */
+ rend_cache_decrement_allocation(cache_get_client_entry_size(desc));
}
/* Store a given descriptor in our cache. */
@@ -608,7 +610,6 @@ cache_store_as_client(hs_cache_client_descriptor_t *client_desc)
}
/* Remove old entry. Make space for the new one! */
remove_v3_desc_as_client(cache_entry);
- rend_cache_decrement_allocation(cache_get_client_entry_size(cache_entry));
cache_client_desc_free(cache_entry);
}
@@ -649,7 +650,8 @@ cache_clean_v3_as_client(time_t now)
bytes_removed += entry_size;
/* Entry is not in the cache anymore, destroy it. */
cache_client_desc_free(entry);
- /* Update our cache entry allocation size for the OOM. */
+ /* 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);
/* Logging. */
{