[or-cvs] r14212: Free some static hashtables and the log mutex on exit. Backp (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Thu Mar 27 15:05:29 UTC 2008


Author: nickm
Date: 2008-03-27 11:05:28 -0400 (Thu, 27 Mar 2008)
New Revision: 14212

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/log.c
   tor/trunk/src/common/tortls.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/policies.c
Log:
 r19089 at catbus:  nickm | 2008-03-27 11:05:23 -0400
 Free some static hashtables and the log mutex on exit. Backport candidate.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r19089] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-03-27 10:27:04 UTC (rev 14211)
+++ tor/trunk/ChangeLog	2008-03-27 15:05:28 UTC (rev 14212)
@@ -17,6 +17,8 @@
       2. Bugfix on 0.2.0.16-alpha.
     - Free authority certificates on exit, so they don't look like memory
       leaks.  Bugfix on 0.2.0.19-alpha.
+    - Free static hashtables for policy maps and for TLS connections on
+      shutdown, so they don't look like memory leaks.  Bugfix on 0.2.0.x.
 
   o Minor features:
     - Allow separate log levels to be configured for different logging

Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c	2008-03-27 10:27:04 UTC (rev 14211)
+++ tor/trunk/src/common/log.c	2008-03-27 15:05:28 UTC (rev 14212)
@@ -431,6 +431,8 @@
     log_free(victim);
   }
   tor_free(appname);
+  tor_mutex_free(log_mutex);
+  log_mutex = NULL;
 }
 
 /** Remove and free the log entry <b>victim</b> from the linked-list

Modified: tor/trunk/src/common/tortls.c
===================================================================
--- tor/trunk/src/common/tortls.c	2008-03-27 10:27:04 UTC (rev 14211)
+++ tor/trunk/src/common/tortls.c	2008-03-27 15:05:28 UTC (rev 14212)
@@ -314,6 +314,10 @@
     tor_tls_context_decref(global_tls_context);
     global_tls_context = NULL;
   }
+  if (!HT_EMPTY(&tlsmap_root)) {
+    log_warn(LD_MM, "Still have entries in the tlsmap at shutdown.");
+  }
+  HT_CLEAR(tlsmap, &tlsmap_root);
 }
 
 /** We need to give OpenSSL a callback to verify certificates. This is

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2008-03-27 10:27:04 UTC (rev 14211)
+++ tor/trunk/src/or/main.c	2008-03-27 15:05:28 UTC (rev 14212)
@@ -1849,13 +1849,15 @@
   entry_guards_free_all();
   connection_free_all();
   buf_shrink_freelists(1);
-  policies_free_all();
   if (!postfork) {
     config_free_all();
     router_free_all();
+    policies_free_all();
   }
   free_cell_pool();
-  tor_tls_free_all();
+  if (!postfork) {
+    tor_tls_free_all();
+  }
   /* stuff in main.c */
   smartlist_free(connection_array);
   smartlist_free(closeable_connection_lst);

Modified: tor/trunk/src/or/policies.c
===================================================================
--- tor/trunk/src/or/policies.c	2008-03-27 10:27:04 UTC (rev 14211)
+++ tor/trunk/src/or/policies.c	2008-03-27 15:05:28 UTC (rev 14212)
@@ -446,7 +446,7 @@
   addr_policy_t *policy;
 } policy_map_ent_t;
 
-static HT_HEAD(policy_map, policy_map_ent_t) policy_root;
+static HT_HEAD(policy_map, policy_map_ent_t) policy_root = HT_INITIALIZER();
 
 /** Return true iff a and b are equal. */
 static INLINE int
@@ -923,5 +923,9 @@
   authdir_reject_policy = NULL;
   addr_policy_list_free(authdir_invalid_policy);
   authdir_invalid_policy = NULL;
+
+  if (!HT_EMPTY(&policy_root))
+    log_warn(LD_MM, "Still had some address policies cached at shutdown.");
+  HT_CLEAR(policy_map, &policy_root);
 }
 



More information about the tor-commits mailing list