From acfa0489910e881254498e2aa8b9f2bb5bafae3b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 20 May 2014 12:21:32 +1000 Subject: [PATCH] Clear notifies completely including the ram and discard all notifies on reconnect --- src/generator.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/generator.c b/src/generator.c index 9c0ee64b..fced81d0 100644 --- a/src/generator.c +++ b/src/generator.c @@ -809,11 +809,28 @@ out: return ret; } +static void clear_notify(notify_instance_t *ni) +{ + free(ni->jobid); + free(ni->coinbase1); + free(ni->coinbase2); + free(ni); +} + static void reconnect_stratum(connsock_t *cs, proxy_instance_t *proxi) { + notify_instance_t *ni, *tmp; ckpool_t *ckp = proxi->ckp; bool ret = true; + /* All our notify data is invalid if we reconnect so discard them */ + mutex_lock(&proxi->notify_lock); + HASH_ITER(hh, proxi->notify_instances, ni, tmp) { + HASH_DEL(proxi->notify_instances, ni); + clear_notify(ni); + } + mutex_unlock(&proxi->notify_lock); + do { if (!ret) sleep(5); @@ -824,16 +841,9 @@ static void reconnect_stratum(connsock_t *cs, proxy_instance_t *proxi) ret = subscribe_stratum(cs, proxi); if (!ret) continue; - send_proc(ckp->stratifier, "subscribe"); ret = auth_stratum(cs, proxi); } while (!ret); -} - -static void clear_notify(notify_instance_t *ni) -{ - free(ni->jobid); - free(ni->coinbase1); - free(ni->coinbase2); + send_proc(ckp->stratifier, "subscribe"); } /* FIXME: Return something useful to the stratifier based on this result */