From cb1e3b86373b4ecf480f9c016065ac9628907519 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 25 Nov 2014 23:01:37 +1100 Subject: [PATCH 1/3] Fine grain create the json share error to debug each field --- src/stratifier.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index d905d081..1741950c 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2516,19 +2516,19 @@ out: } if (!share) { - JSON_CPACK(val, "{sI,ss,ss,sI,ss,ss,so,si,ss,ss,ss,ss}", - "clientid", client->id, - "secondaryuserid", user_instance->secondaryuserid, - "enonce1", client->enonce1, - "workinfoid", current_workbase->id, - "workername", client->workername, - "username", user_instance->username, - "error", json_copy(*err_val), - "errn", err, - "createdate", cdfield, - "createby", "code", - "createcode", __func__, - "createinet", ckp->serverurl); + val = json_object(); + json_set_int(val, "clientid", client->id); + json_set_string(val, "secondaryuserid", user_instance->secondaryuserid); + json_set_string(val, "enonce1", client->enonce1); + json_set_int(val, "workinfoid", current_workbase->id); + json_set_string(val, "workername", client->workername); + json_set_string(val, "username", user_instance->username); + json_object_set(val, "error", *err_val); + json_set_int(val, "errn", err); + json_set_string(val, "createdate", cdfield); + json_set_string(val, "createby", "code"); + json_set_string(val, "createcode", __func__); + json_set_string(val, "createinet", ckp->serverurl); ckdbq_add(ckp, ID_SHAREERR, val); LOGINFO("Invalid share from client %ld: %s", client->id, client->workername); } From 807d5a403cd3f56e17ee6884a8f3392ddc56dc52 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 25 Nov 2014 23:25:58 +1100 Subject: [PATCH 2/3] Only add secondaryuserid with ckdb --- src/stratifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 1741950c..c248f7aa 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2518,7 +2518,8 @@ out: if (!share) { val = json_object(); json_set_int(val, "clientid", client->id); - json_set_string(val, "secondaryuserid", user_instance->secondaryuserid); + if (!CKP_STANDALONE(ckp)) + json_set_string(val, "secondaryuserid", user_instance->secondaryuserid); json_set_string(val, "enonce1", client->enonce1); json_set_int(val, "workinfoid", current_workbase->id); json_set_string(val, "workername", client->workername); From c57782af25ee1b3c6b5620400f06411aa613d928 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 25 Nov 2014 23:32:46 +1100 Subject: [PATCH 3/3] Avoid variable names in json checking macros that may conflict --- src/libckpool.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libckpool.h b/src/libckpool.h index 93323d9c..b6d3c8f7 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -279,13 +279,13 @@ typedef struct proc_instance proc_instance_t; void _json_check(json_t *val, json_error_t *err, const char *file, const char *func, const int line); -#define json_check(val, err) _json_check(val, err, __FILE__, __func__, __LINE__) +#define json_check(VAL, ERR) _json_check(VAL, ERR, __FILE__, __func__, __LINE__) /* Check and pack json */ -#define JSON_CPACK(val, ...) do { \ - json_error_t err; \ - val = json_pack_ex(&err, 0, ##__VA_ARGS__); \ - json_check(val, &err); \ +#define JSON_CPACK(VAL, ...) do { \ + json_error_t ERR; \ + VAL = json_pack_ex(&ERR, 0, ##__VA_ARGS__); \ + json_check(VAL, &ERR); \ } while (0) /* No error checking with these, make sure we know they're valid already! */