diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2010-12-11 05:26:36 -0800 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2010-12-11 05:26:36 -0800 |
commit | cc051f9aca96b55533953cfcc10c86f9fe1e7b9a (patch) | |
tree | 8abb7c7f6b58e8915c9d97f4e81fe5dda6099a48 /src/common/log.c | |
parent | 4a9d60734ce47cb3b5cb254e522116cd26b4823f (diff) | |
download | tor-cc051f9aca96b55533953cfcc10c86f9fe1e7b9a.tar.gz tor-cc051f9aca96b55533953cfcc10c86f9fe1e7b9a.zip |
Only add each log message to pending_cb_messages once.
Diffstat (limited to 'src/common/log.c')
-rw-r--r-- | src/common/log.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/common/log.c b/src/common/log.c index f63c3fb9b4..1324ff08c9 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); } |