aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Ransom <rransom.8774@gmail.com>2010-12-11 05:26:36 -0800
committerRobert Ransom <rransom.8774@gmail.com>2010-12-11 05:26:36 -0800
commitcc051f9aca96b55533953cfcc10c86f9fe1e7b9a (patch)
tree8abb7c7f6b58e8915c9d97f4e81fe5dda6099a48 /src
parent4a9d60734ce47cb3b5cb254e522116cd26b4823f (diff)
downloadtor-cc051f9aca96b55533953cfcc10c86f9fe1e7b9a.tar
tor-cc051f9aca96b55533953cfcc10c86f9fe1e7b9a.tar.gz
Only add each log message to pending_cb_messages once.
Diffstat (limited to 'src')
-rw-r--r--src/common/log.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/common/log.c b/src/common/log.c
index f63c3fb9b..1324ff08c 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -272,6 +272,7 @@ logv(int severity, log_domain_mask_t domain, const char *funcname,
int formatted = 0;
logfile_t *lf;
char *end_of_prefix=NULL;
+ int callbacks_deferred = 0;
/* Call assert, not tor_assert, since tor_assert calls log on failure. */
assert(format);
@@ -328,11 +329,15 @@ logv(int severity, log_domain_mask_t domain, const char *funcname,
continue;
} else if (lf->callback) {
if (domain & LD_NOCB) {
- pending_cb_message_t *msg = tor_malloc(sizeof(pending_cb_message_t));
- msg->severity = severity;
- msg->domain = domain;
- msg->msg = tor_strdup(end_of_prefix);
- smartlist_add(pending_cb_messages, msg);
+ if (!callbacks_deferred) {
+ pending_cb_message_t *msg = tor_malloc(sizeof(pending_cb_message_t));
+ msg->severity = severity;
+ msg->domain = domain;
+ msg->msg = tor_strdup(end_of_prefix);
+ smartlist_add(pending_cb_messages, msg);
+
+ callbacks_deferred = 1;
+ }
} else {
lf->callback(severity, domain, end_of_prefix);
}