aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-02-28 22:38:00 +0000
committerNick Mathewson <nickm@torproject.org>2005-02-28 22:38:00 +0000
commit349ee1abea59083b14bddf1470afe9d25d22b43c (patch)
tree951c4b311657beb12eb02aa8be0eaf0b2dd29ca6
parent331badb6ef05936c9f1a6ff6c3385eedc2180ee0 (diff)
downloadtor-349ee1abea59083b14bddf1470afe9d25d22b43c.tar.gz
tor-349ee1abea59083b14bddf1470afe9d25d22b43c.zip
Clean up rend cache on shutdown
svn:r3714
-rw-r--r--src/or/main.c1
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/rendcommon.c20
3 files changed, 19 insertions, 3 deletions
diff --git a/src/or/main.c b/src/or/main.c
index d440ba9a8f..3a1984d768 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1255,6 +1255,7 @@ void tor_free_all(void)
free_dir_policy();
dirserv_free_all();
rend_service_free_all();
+ rend_cache_free_all();
rep_hist_free_all();
dns_free_all();
clear_pending_onions();
diff --git a/src/or/or.h b/src/or/or.h
index 705cfd4cf9..a69f4b1c61 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1586,6 +1586,7 @@ typedef struct rend_cache_entry_t {
void rend_cache_init(void);
void rend_cache_clean(void);
+void rend_cache_free_all(void);
int rend_valid_service_id(const char *query);
int rend_cache_lookup_desc(const char *query, const char **desc, size_t *desc_len);
int rend_cache_lookup_entry(const char *query, rend_cache_entry_t **entry_out);
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 090b803785..ffe5093ad3 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -170,6 +170,22 @@ void rend_cache_init(void)
rend_cache = strmap_new();
}
+static void
+_rend_cache_entry_free(void *p)
+{
+ rend_cache_entry_t *e = p;
+ rend_service_descriptor_free(e->parsed);
+ tor_free(e->desc);
+ tor_free(e);
+}
+
+void
+rend_cache_free_all(void)
+{
+ strmap_free(rend_cache, _rend_cache_entry_free);
+ rend_cache = NULL;
+}
+
/** Removes all old entries from the service descriptor cache.
*/
void rend_cache_clean(void)
@@ -185,9 +201,7 @@ void rend_cache_clean(void)
ent = (rend_cache_entry_t*)val;
if (ent->parsed->timestamp < cutoff) {
iter = strmap_iter_next_rmv(rend_cache, iter);
- rend_service_descriptor_free(ent->parsed);
- tor_free(ent->desc);
- tor_free(ent);
+ _rend_cache_entry_free(ent);
} else {
iter = strmap_iter_next(rend_cache, iter);
}