[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] prop224: Add a cache free all function



commit 1eed6edf36d57c5f80a13a6884afda798fa2abcd
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Fri Sep 16 16:39:01 2016 -0400

    prop224: Add a cache free all function
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/or/hs_cache.c | 16 ++++++++++++++++
 src/or/hs_cache.h |  1 +
 src/or/main.c     |  1 +
 3 files changed, 18 insertions(+)

diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c
index ec98b47..868f936 100644
--- a/src/or/hs_cache.c
+++ b/src/or/hs_cache.c
@@ -56,6 +56,15 @@ cache_dir_desc_free(hs_cache_dir_descriptor_t *desc)
   tor_free(desc);
 }
 
+/* Helper function: Use by the free all function using the digest256map
+ * interface to cache entries. */
+static void
+cache_dir_desc_free_(void *ptr)
+{
+  hs_cache_dir_descriptor_t *desc = ptr;
+  cache_dir_desc_free(desc);
+}
+
 /* Create a new directory cache descriptor object from a encoded descriptor.
  * On success, return the heap-allocated cache object, otherwise return NULL if
  * we can't decode the descriptor. */
@@ -366,3 +375,10 @@ hs_cache_init(void)
   hs_cache_v3_dir = digest256map_new();
 }
 
+/* Cleanup the hidden service cache subsystem. */
+void
+hs_cache_free_all(void)
+{
+  tor_assert(hs_cache_v3_dir);
+  digest256map_free(hs_cache_v3_dir, cache_dir_desc_free_);
+}
diff --git a/src/or/hs_cache.h b/src/or/hs_cache.h
index 88f84c1..01abb80 100644
--- a/src/or/hs_cache.h
+++ b/src/or/hs_cache.h
@@ -40,6 +40,7 @@ typedef struct hs_cache_dir_descriptor_t {
 /* Public API */
 
 void hs_cache_init(void);
+void hs_cache_free_all(void);
 void hs_cache_clean_as_dir(time_t now);
 size_t hs_cache_handle_oom(time_t now, size_t min_remove_bytes);
 
diff --git a/src/or/main.c b/src/or/main.c
index 9defdf0..6876236 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2958,6 +2958,7 @@ tor_free_all(int postfork)
   rend_service_free_all();
   rend_cache_free_all();
   rend_service_authorization_free_all();
+  hs_cache_free_all();
   rep_hist_free_all();
   dns_free_all();
   clear_pending_onions();



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits