From a5d526a67d39f78758070b06a364d593535b5908 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 29 Jul 2016 11:37:17 +1000 Subject: [PATCH] Delete parent proxies once all their subproxies are dead --- src/stratifier.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index d3efb0f2..a737fae7 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2727,6 +2727,11 @@ static void reap_proxies(ckpool_t *ckp, sdata_t *sdata) proxy->subproxy_count--; free_proxy(subproxy); } + /* Should we reap the parent proxy too?*/ + if (!proxy->dead || proxy->subproxy_count > 1 || proxy->bound_clients) + continue; + HASH_DELETE(hh, sdata->proxies, proxy); + free_proxy(proxy); } mutex_unlock(&sdata->proxy_lock); @@ -3414,12 +3419,13 @@ static void reconnect_client(sdata_t *sdata, stratum_instance_t *client) stratum_add_send(sdata, json_msg, client->id, SM_RECONNECT); } -static void dead_proxy(sdata_t *sdata, const char *buf) +static void dead_proxy(ckpool_t *ckp, sdata_t *sdata, const char *buf) { int id = 0, subid = 0; sscanf(buf, "deadproxy=%d:%d", &id, &subid); dead_proxyid(sdata, id, subid, false); + reap_proxies(ckp, sdata); } static void reconnect_client_id(sdata_t *sdata, const int64_t client_id) @@ -4108,7 +4114,7 @@ retry: } else if (cmdmatch(buf, "reconnect")) { request_reconnect(sdata, buf); } else if (cmdmatch(buf, "deadproxy")) { - dead_proxy(sdata, buf); + dead_proxy(ckp, sdata, buf); } else if (cmdmatch(buf, "loglevel")) { sscanf(buf, "loglevel=%d", &ckp->loglevel); } else if (cmdmatch(buf, "ckdbflush")) {