Browse Source

Do all reconnects on stratum notify lazily only to prevent multiple subproxies flagging reconnects

master
Con Kolivas 10 years ago
parent
commit
804a98e63c
  1. 18
      src/stratifier.c

18
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) static void reconnect_clients(sdata_t *sdata)
{ {
stratum_instance_t *client, *tmpclient; stratum_instance_t *client, *tmpclient;
int reconnects = 0, hard = 0; int reconnects = 0;
int64_t headroom; int64_t headroom;
proxy_t *proxy; proxy_t *proxy;
@ -1354,15 +1354,11 @@ static void reconnect_clients(sdata_t *sdata)
continue; continue;
if (client->proxyid == proxy->id) if (client->proxyid == proxy->id)
continue; continue;
if (client->reconnect)
continue;
if (headroom-- < 1) if (headroom-- < 1)
continue; continue;
reconnects++; 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); 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); int64_t headroom = proxy_headroom(sdata, userid);
stratum_instance_t *client, *tmpclient; stratum_instance_t *client, *tmpclient;
int reconnects = 0, hard = 0; int reconnects = 0;
ck_rlock(&sdata->instance_lock); ck_rlock(&sdata->instance_lock);
HASH_ITER(hh, sdata->stratum_instances, client, tmpclient) { HASH_ITER(hh, sdata->stratum_instances, client, tmpclient) {
@ -1597,13 +1593,11 @@ static void check_userproxies(sdata_t *sdata, const int userid)
continue; continue;
if (client->proxy->userid == userid) if (client->proxy->userid == userid)
continue; continue;
if (client->reconnect)
continue;
if (headroom-- < 1) if (headroom-- < 1)
continue; continue;
reconnects++; reconnects++;
if (client->reconnect && hard <= SOMAXCONN / 2) {
hard++;
reconnect_client(sdata, client);
} else
client->reconnect = true; client->reconnect = true;
} }
ck_runlock(&sdata->instance_lock); ck_runlock(&sdata->instance_lock);

Loading…
Cancel
Save