From 804a98e63c3777e0e5251e32c53a47fcf3c21131 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 21 Mar 2015 22:17:47 +1100 Subject: [PATCH] Do all reconnects on stratum notify lazily only to prevent multiple subproxies flagging reconnects --- src/stratifier.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index bffa5080..b3ba8815 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1335,7 +1335,7 @@ static void generator_recruit(const ckpool_t *ckp, const int proxyid, const int static void reconnect_clients(sdata_t *sdata) { stratum_instance_t *client, *tmpclient; - int reconnects = 0, hard = 0; + int reconnects = 0; int64_t headroom; proxy_t *proxy; @@ -1354,16 +1354,12 @@ static void reconnect_clients(sdata_t *sdata) continue; if (client->proxyid == proxy->id) continue; + if (client->reconnect) + continue; if (headroom-- < 1) continue; reconnects++; - /* Limit reconnects sent concurrently to prevent a flood of new - * connections */ - if (client->reconnect && hard <= SOMAXCONN / 2) { - hard++; - reconnect_client(sdata, client); - } else - client->reconnect = true; + client->reconnect = true; } ck_runlock(&sdata->instance_lock); @@ -1585,7 +1581,7 @@ static void check_userproxies(sdata_t *sdata, const int userid) { int64_t headroom = proxy_headroom(sdata, userid); stratum_instance_t *client, *tmpclient; - int reconnects = 0, hard = 0; + int reconnects = 0; ck_rlock(&sdata->instance_lock); HASH_ITER(hh, sdata->stratum_instances, client, tmpclient) { @@ -1597,14 +1593,12 @@ static void check_userproxies(sdata_t *sdata, const int userid) continue; if (client->proxy->userid == userid) continue; + if (client->reconnect) + continue; if (headroom-- < 1) continue; reconnects++; - if (client->reconnect && hard <= SOMAXCONN / 2) { - hard++; - reconnect_client(sdata, client); - } else - client->reconnect = true; + client->reconnect = true; } ck_runlock(&sdata->instance_lock);