From 1479303138721f46b9dfadb7a8846b4c7394b1e3 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 d9e646bb..cead06a9 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -437,6 +437,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;