From d4cd88ac585dd7cf4900b022f7678f1bae975fba Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 28 Feb 2015 11:53:48 +1100 Subject: [PATCH] Add helper functions for storing messages to be dumped outside of other locks --- src/stratifier.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index e4f22fcb..bd34bcbc 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -404,6 +404,29 @@ static const char *ckdb_ids[] = { "heartbeat" }; +/* For storing a set of messages within another lock, allowing us to dump them + * to the log outside of lock */ +static void add_msg_entry(char_entry_t **entries, char **buf) +{ + char_entry_t *entry = ckalloc(sizeof(char_entry_t)); + + entry->buf = *buf; + *buf = NULL; + DL_APPEND(*entries, entry); +} + +static void notice_msg_entries(char_entry_t **entries) +{ + char_entry_t *entry, *tmpentry; + + DL_FOREACH_SAFE(*entries, entry, tmpentry) { + DL_DELETE(*entries, entry); + LOGNOTICE("%s", entry->buf); + free(entry->buf); + free(entry); + } +} + static void generate_coinbase(const ckpool_t *ckp, workbase_t *wb) { uint64_t *u64, g64, d64 = 0;