|
|
@ -1163,10 +1163,9 @@ static void reconnect_clients(sdata_t *sdata) |
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmpclient) { |
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmpclient) { |
|
|
|
if (client->proxyid == proxy->id) |
|
|
|
if (client->proxyid == proxy->id) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if (--headroom < 0) |
|
|
|
headroom--; |
|
|
|
break; |
|
|
|
|
|
|
|
reconnects++; |
|
|
|
reconnects++; |
|
|
|
if (client->reconnect) |
|
|
|
if (client->reconnect && headroom > 0) |
|
|
|
reconnect_client(sdata, client); |
|
|
|
reconnect_client(sdata, client); |
|
|
|
else |
|
|
|
else |
|
|
|
client->reconnect = true; |
|
|
|
client->reconnect = true; |
|
|
@ -1174,12 +1173,11 @@ static void reconnect_clients(sdata_t *sdata) |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
if (reconnects) { |
|
|
|
if (reconnects) { |
|
|
|
LOGNOTICE("Flagged %d clients for reconnect to proxy %d", reconnects, |
|
|
|
LOGNOTICE("%d clients flagged for reconnect to proxy %d", reconnects, |
|
|
|
proxy->id); |
|
|
|
proxy->id); |
|
|
|
if (headroom < 42) |
|
|
|
if (headroom < 42) |
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
} else if (headroom < 0) |
|
|
|
} |
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static proxy_t *current_proxy(sdata_t *sdata) |
|
|
|
static proxy_t *current_proxy(sdata_t *sdata) |
|
|
@ -1197,13 +1195,20 @@ static void dead_parent_proxy(sdata_t *sdata, const int id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
stratum_instance_t *client, *tmp; |
|
|
|
stratum_instance_t *client, *tmp; |
|
|
|
int reconnects = 0; |
|
|
|
int reconnects = 0; |
|
|
|
|
|
|
|
int64_t headroom; |
|
|
|
|
|
|
|
proxy_t *proxy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
headroom = current_headroom(sdata, &proxy); |
|
|
|
|
|
|
|
if (!proxy) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
ck_rlock(&sdata->instance_lock); |
|
|
|
ck_rlock(&sdata->instance_lock); |
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmp) { |
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmp) { |
|
|
|
if (client->proxyid != id || client->subproxyid) |
|
|
|
if (client->proxyid != id || client->subproxyid) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
headroom--; |
|
|
|
reconnects++; |
|
|
|
reconnects++; |
|
|
|
if (client->reconnect) |
|
|
|
if (client->reconnect && headroom > 0) |
|
|
|
reconnect_client(sdata, client); |
|
|
|
reconnect_client(sdata, client); |
|
|
|
else |
|
|
|
else |
|
|
|
client->reconnect = true; |
|
|
|
client->reconnect = true; |
|
|
@ -1211,8 +1216,10 @@ static void dead_parent_proxy(sdata_t *sdata, const int id) |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
if (reconnects) { |
|
|
|
if (reconnects) { |
|
|
|
LOGNOTICE("Flagged %d clients to reconnect from dead proxy %d", |
|
|
|
LOGNOTICE("%d clients flagged to reconnect from dead proxy %d", |
|
|
|
reconnects, id); |
|
|
|
reconnects, id); |
|
|
|
|
|
|
|
if (headroom < 42) |
|
|
|
|
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2253,10 +2260,9 @@ static void dead_proxy(sdata_t *sdata, const char *buf) |
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmp) { |
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmp) { |
|
|
|
if (client->proxyid != id || client->subproxyid != subid) |
|
|
|
if (client->proxyid != id || client->subproxyid != subid) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if (--headroom < 0) |
|
|
|
headroom--; |
|
|
|
break; |
|
|
|
|
|
|
|
reconnects++; |
|
|
|
reconnects++; |
|
|
|
if (client->reconnect) |
|
|
|
if (client->reconnect && headroom > 0) |
|
|
|
reconnect_client(sdata, client); |
|
|
|
reconnect_client(sdata, client); |
|
|
|
else |
|
|
|
else |
|
|
|
client->reconnect = true; |
|
|
|
client->reconnect = true; |
|
|
@ -2264,12 +2270,11 @@ static void dead_proxy(sdata_t *sdata, const char *buf) |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
if (reconnects) { |
|
|
|
if (reconnects) { |
|
|
|
LOGNOTICE("Flagged %d clients to reconnect from dead proxy %d:%d", reconnects, |
|
|
|
LOGNOTICE("%d clients flagged to reconnect from dead proxy %d:%d", reconnects, |
|
|
|
id, subid); |
|
|
|
id, subid); |
|
|
|
if (headroom < 42) |
|
|
|
if (headroom < 42) |
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
} else if (headroom < 0) |
|
|
|
} |
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Must hold a reference */ |
|
|
|
/* Must hold a reference */ |
|
|
|