From fd7c1154313545f62eb3d3073addaa941cb21e1a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Aug 2014 12:03:29 +1000 Subject: [PATCH 1/2] Drop all clients and reject incoming connections when we fail to talk to the upstream pool in proxy mode --- src/generator.c | 2 ++ src/stratifier.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/generator.c b/src/generator.c index 03bc9fd9..96eac99e 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1289,6 +1289,8 @@ retry: break; } if (!alive) { + send_proc(ckp->stratifier, "dropall"); + send_proc(ckp->connector, "reject"); if (!ckp->chosen_server) { LOGWARNING("Failed to connect to any servers as proxy, retrying in 5s!"); sleep(5); diff --git a/src/stratifier.c b/src/stratifier.c index e122f5e6..387d3a19 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1090,6 +1090,8 @@ retry: LOGDEBUG("Stratifier failed to parse dropclient command: %s", buf); else drop_client(client_id); + } else if (cmdmatch(buf, "dropall")) { + drop_allclients(ckp); } else if (cmdmatch(buf, "block")) { block_solve(ckp); } else if (cmdmatch(buf, "loglevel")) { From 4b8de19e070f956afc5f32dce6d283f0d4a9815f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Aug 2014 12:22:27 +1000 Subject: [PATCH 2/2] Add sanity check to decay time to prevent underflow levels of small numbers --- src/libckpool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libckpool.c b/src/libckpool.c index ea45487d..e4f9bd3b 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -1536,6 +1536,10 @@ void decay_time(double *f, double fadd, double fsecs, double interval) ftotal = 1.0 + fprop; *f += (fadd / fsecs * fprop); *f /= ftotal; + /* Sanity check to prevent meaningless super small numbers that + * eventually underflow libjansson's real number interpretation. */ + if (unlikely(*f < 2E-16)) + *f = 0; } /* Convert a double value into a truncated string for displaying with its