From 65a8b3d9fbd8dd7090a277e456c5c73a5c05d5d3 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 20 May 2014 11:06:39 +1000 Subject: [PATCH] Drop proxy connections on failing to submit messages --- src/generator.c | 9 +++++++-- src/stratifier.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/generator.c b/src/generator.c index ae88a773..a805b166 100644 --- a/src/generator.c +++ b/src/generator.c @@ -269,7 +269,7 @@ out: static json_t *find_notify(json_t *val) { int arr_size, i; - json_t *ret; + json_t *ret = NULL; const char *entry; if (!json_is_array(val)) @@ -951,6 +951,7 @@ static void *proxy_send(void *arg) char *jobid; json_t *val; uint32_t id; + bool ret; mutex_lock(&proxi->psend_lock); if (!proxi->psends) @@ -982,10 +983,14 @@ static void *proxy_send(void *arg) "id", json_object_get(msg->json_msg, "id"), "method", "mining.submit"); free(jobid); - send_json_msg(cs, val); + ret = send_json_msg(cs, val); json_decref(val); json_decref(msg->json_msg); free(msg); + if (!ret) { + LOGWARNING("Failed to send msg in proxy_send, dropping to reconnect"); + close(cs->fd); + } } return NULL; } diff --git a/src/stratifier.c b/src/stratifier.c index 5e10267c..ffd2404d 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1300,7 +1300,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, bool share = false, result = false, invalid = true, submit = false; const char *user, *job_id, *nonce2, *ntime, *nonce; char hexhash[68], sharehash[32], *logdir; - double diff, wdiff, sdiff = -1; + double diff, wdiff = 0, sdiff = -1; char idstring[20]; uint32_t ntime32; char *fname, *s;