aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-03-27 15:05:28 +0000
committerNick Mathewson <nickm@torproject.org>2008-03-27 15:05:28 +0000
commit02acee891c9898e510bb21e4a6b88e44ff4a13f9 (patch)
treea0410637ae1688d18327205b21c7aa529e147fc6
parent03078f7f7a9aec4aa94b05f71d92458ec865b9a0 (diff)
downloadtor-02acee891c9898e510bb21e4a6b88e44ff4a13f9.tar
tor-02acee891c9898e510bb21e4a6b88e44ff4a13f9.tar.gz
r19089@catbus: nickm | 2008-03-27 11:05:23 -0400
Free some static hashtables and the log mutex on exit. Backport candidate. svn:r14212
-rw-r--r--ChangeLog2
-rw-r--r--src/common/log.c2
-rw-r--r--src/common/tortls.c4
-rw-r--r--src/or/main.c6
-rw-r--r--src/or/policies.c6
5 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 4acbf3f18..dcb8e99c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,8 @@ Changes in version 0.2.1.1-alpha - 2008-??-??
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
diff --git a/src/common/log.c b/src/common/log.c
index aa13db9f0..0f59a93ac 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -431,6 +431,8 @@ logs_free_all(void)
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
diff --git a/src/common/tortls.c b/src/common/tortls.c
index ac2f8ebc8..07cf17bc1 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -314,6 +314,10 @@ tor_tls_free_all(void)
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
diff --git a/src/or/main.c b/src/or/main.c
index b569efde1..6c75c3976 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1849,13 +1849,15 @@ tor_free_all(int postfork)
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);
diff --git a/src/or/policies.c b/src/or/policies.c
index 31b7917e9..2e66a0032 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -446,7 +446,7 @@ typedef struct policy_map_ent_t {
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 @@ policies_free_all(void)
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);
}