summaryrefslogtreecommitdiff
path: root/src/common/log.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-04-07 15:25:33 -0400
committerNick Mathewson <nickm@torproject.org>2011-04-07 15:25:33 -0400
commit1be12213857e3c5068107f4df047cea03b6462e8 (patch)
tree4c7da2f7c59942374f40f86347eb2c724e8be03f /src/common/log.c
parent403b6cfdedee7ebc8fe0b5d1c187e8ae3611aec1 (diff)
downloadtor-1be12213857e3c5068107f4df047cea03b6462e8.tar.gz
tor-1be12213857e3c5068107f4df047cea03b6462e8.zip
Free pending_cb_messages on exit
Diffstat (limited to 'src/common/log.c')
-rw-r--r--src/common/log.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 28d002967b..d14563c885 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -363,7 +363,7 @@ logv(int severity, log_domain_mask_t domain, const char *funcname,
continue;
} else if (lf->callback) {
if (domain & LD_NOCB) {
- if (!callbacks_deferred) {
+ if (!callbacks_deferred && pending_cb_messages) {
pending_cb_message_t *msg = tor_malloc(sizeof(pending_cb_message_t));
msg->severity = severity;
msg->domain = domain;
@@ -512,9 +512,12 @@ void
logs_free_all(void)
{
logfile_t *victim, *next;
+ smartlist_t *messages;
LOCK_LOGS();
next = logfiles;
logfiles = NULL;
+ messages = pending_cb_messages;
+ pending_cb_messages = NULL;
UNLOCK_LOGS();
while (next) {
victim = next;
@@ -524,6 +527,12 @@ logs_free_all(void)
}
tor_free(appname);
+ SMARTLIST_FOREACH(messages, pending_cb_message_t *, msg, {
+ tor_free(msg->msg);
+ tor_free(msg);
+ });
+ smartlist_free(messages);
+
/* We _could_ destroy the log mutex here, but that would screw up any logs
* that happened between here and the end of execution. */
}