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

[or-cvs] Clean up rend cache on shutdown



Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv13446/src/or

Modified Files:
	main.c or.h rendcommon.c 
Log Message:
Clean up rend cache on shutdown

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.454
retrieving revision 1.455
diff -u -d -r1.454 -r1.455
--- main.c	28 Feb 2005 02:52:51 -0000	1.454
+++ main.c	28 Feb 2005 22:38:00 -0000	1.455
@@ -1255,6 +1255,7 @@
   free_dir_policy();
   dirserv_free_all();
   rend_service_free_all();
+  rend_cache_free_all();
   rep_hist_free_all();
   dns_free_all();
   clear_pending_onions();

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.543
retrieving revision 1.544
diff -u -d -r1.543 -r1.544
--- or.h	27 Feb 2005 09:47:01 -0000	1.543
+++ or.h	28 Feb 2005 22:38:00 -0000	1.544
@@ -1586,6 +1586,7 @@
 
 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);

Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendcommon.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- rendcommon.c	19 Jan 2005 23:15:59 -0000	1.44
+++ rendcommon.c	28 Feb 2005 22:38:00 -0000	1.45
@@ -170,6 +170,22 @@
   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 @@
     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);
     }