From eff11a1024f3e7affce1554646186c0a34095c9d Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 2 Aug 2014 15:50:55 +1000 Subject: [PATCH] Avoid trying to send a message to ckdb if it's invalid json and identify where it came from --- src/stratifier.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index e8a98cc7..14d7cb85 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -415,7 +415,8 @@ static void purge_share_hashtable(int64_t wb_id) static char *status_chars = "|/-\\"; -static void ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val) +static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char *file, + const char *func, const int line) { static int counter = 0; ckdb_msg_t *msg; @@ -425,6 +426,11 @@ static void ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val) fprintf(stdout, "%c\r", ch); fflush(stdout); + if (!val) { + LOGWARNING("Invalid json sent to ckdbq_add from %s %s:%d", file, func, line); + return; + } + if (ckp->standalone) return json_decref(val); @@ -434,6 +440,8 @@ static void ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val) ckmsgq_add(ckdbq, msg); } +#define ckdbq_add(ckp, idtype, val) _ckdbq_add(ckp, idtype, val, __FILE__, __func__, __LINE__) + static void send_workinfo(ckpool_t *ckp, workbase_t *wb) { char cdfield[64];