|
|
@ -1067,15 +1067,6 @@ out: |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void stratum_add_recvd(json_t *val) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
smsg_t *msg; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msg = ckzalloc(sizeof(smsg_t)); |
|
|
|
|
|
|
|
msg->json_msg = val; |
|
|
|
|
|
|
|
ckmsgq_add(srecvs, msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* For creating a list of sends without locking that can then be concatenated
|
|
|
|
/* For creating a list of sends without locking that can then be concatenated
|
|
|
|
* to the stratum_sends list. Minimises locking and avoids taking recursive |
|
|
|
* to the stratum_sends list. Minimises locking and avoids taking recursive |
|
|
|
* locks. */ |
|
|
|
* locks. */ |
|
|
@ -1404,12 +1395,9 @@ retry: |
|
|
|
} else if (cmdmatch(buf, "loglevel")) { |
|
|
|
} else if (cmdmatch(buf, "loglevel")) { |
|
|
|
sscanf(buf, "loglevel=%d", &ckp->loglevel); |
|
|
|
sscanf(buf, "loglevel=%d", &ckp->loglevel); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
json_t *val = json_loads(buf, 0, NULL); |
|
|
|
/* The srecv_process frees the buf heap ram */ |
|
|
|
|
|
|
|
ckmsgq_add(srecvs, buf); |
|
|
|
if (!val) { |
|
|
|
buf = NULL; |
|
|
|
LOGWARNING("Received unrecognised message: %s", buf); |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
stratum_add_recvd(val); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|
|
|
|
|
|
|
|
@ -2833,21 +2821,25 @@ out: |
|
|
|
free(msg); |
|
|
|
free(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void srecv_process(ckpool_t *ckp, smsg_t *msg) |
|
|
|
static void srecv_process(ckpool_t *ckp, char *buf) |
|
|
|
{ |
|
|
|
{ |
|
|
|
stratum_instance_t *instance; |
|
|
|
stratum_instance_t *instance; |
|
|
|
|
|
|
|
smsg_t *msg; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = json_loads(buf, 0, NULL); |
|
|
|
|
|
|
|
if (unlikely(!val)) { |
|
|
|
|
|
|
|
LOGWARNING("Received unrecognised non-json message: %s", buf); |
|
|
|
|
|
|
|
goto out; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
msg = ckzalloc(sizeof(smsg_t)); |
|
|
|
|
|
|
|
msg->json_msg = val; |
|
|
|
val = json_object_get(msg->json_msg, "client_id"); |
|
|
|
val = json_object_get(msg->json_msg, "client_id"); |
|
|
|
if (unlikely(!val)) { |
|
|
|
if (unlikely(!val)) { |
|
|
|
char *s; |
|
|
|
LOGWARNING("Failed to extract client_id from connector json smsg %s", buf); |
|
|
|
|
|
|
|
|
|
|
|
s = json_dumps(msg->json_msg, 0); |
|
|
|
|
|
|
|
LOGWARNING("Failed to extract client_id from connector json smsg %s", s); |
|
|
|
|
|
|
|
free(s); |
|
|
|
|
|
|
|
json_decref(msg->json_msg); |
|
|
|
json_decref(msg->json_msg); |
|
|
|
free(msg); |
|
|
|
free(msg); |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
msg->client_id = json_integer_value(val); |
|
|
|
msg->client_id = json_integer_value(val); |
|
|
@ -2855,14 +2847,10 @@ static void srecv_process(ckpool_t *ckp, smsg_t *msg) |
|
|
|
|
|
|
|
|
|
|
|
val = json_object_get(msg->json_msg, "address"); |
|
|
|
val = json_object_get(msg->json_msg, "address"); |
|
|
|
if (unlikely(!val)) { |
|
|
|
if (unlikely(!val)) { |
|
|
|
char *s; |
|
|
|
LOGWARNING("Failed to extract address from connector json smsg %s", buf); |
|
|
|
|
|
|
|
|
|
|
|
s = json_dumps(msg->json_msg, 0); |
|
|
|
|
|
|
|
LOGWARNING("Failed to extract address from connector json smsg %s", s); |
|
|
|
|
|
|
|
free(s); |
|
|
|
|
|
|
|
json_decref(msg->json_msg); |
|
|
|
json_decref(msg->json_msg); |
|
|
|
free(msg); |
|
|
|
free(msg); |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
strcpy(msg->address, json_string_value(val)); |
|
|
|
strcpy(msg->address, json_string_value(val)); |
|
|
|
json_object_clear(val); |
|
|
|
json_object_clear(val); |
|
|
@ -2877,7 +2865,8 @@ static void srecv_process(ckpool_t *ckp, smsg_t *msg) |
|
|
|
ck_wunlock(&instance_lock); |
|
|
|
ck_wunlock(&instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
parse_instance_msg(msg); |
|
|
|
parse_instance_msg(msg); |
|
|
|
|
|
|
|
out: |
|
|
|
|
|
|
|
free(buf); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void discard_stratum_msg(smsg_t **msg) |
|
|
|
static void discard_stratum_msg(smsg_t **msg) |
|
|
|