|
|
@ -1160,10 +1160,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 < 1) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
headroom--; |
|
|
|
|
|
|
|
reconnects++; |
|
|
|
reconnects++; |
|
|
|
|
|
|
|
if (headroom-- < 1) |
|
|
|
|
|
|
|
break; |
|
|
|
if (client->reconnect) |
|
|
|
if (client->reconnect) |
|
|
|
reconnect_client(sdata, client); |
|
|
|
reconnect_client(sdata, client); |
|
|
|
else |
|
|
|
else |
|
|
@ -1174,9 +1173,9 @@ static void reconnect_clients(sdata_t *sdata) |
|
|
|
if (reconnects) { |
|
|
|
if (reconnects) { |
|
|
|
LOGNOTICE("%d clients flagged for reconnect to proxy %ld", reconnects, |
|
|
|
LOGNOTICE("%d clients flagged for reconnect to proxy %ld", reconnects, |
|
|
|
proxy->id); |
|
|
|
proxy->id); |
|
|
|
|
|
|
|
if (headroom < 42) |
|
|
|
|
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
} |
|
|
|
} |
|
|
|
if (headroom < 42) |
|
|
|
|
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
#if 0 |
|
|
@ -1209,10 +1208,9 @@ static void dead_proxyid(sdata_t *sdata, const int64_t id, const int subid) |
|
|
|
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 < 1) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
headroom--; |
|
|
|
|
|
|
|
reconnects++; |
|
|
|
reconnects++; |
|
|
|
|
|
|
|
if (headroom-- < 1) |
|
|
|
|
|
|
|
break; |
|
|
|
if (client->reconnect) |
|
|
|
if (client->reconnect) |
|
|
|
reconnect_client(sdata, client); |
|
|
|
reconnect_client(sdata, client); |
|
|
|
else |
|
|
|
else |
|
|
@ -1223,43 +1221,15 @@ static void dead_proxyid(sdata_t *sdata, const int64_t id, const int subid) |
|
|
|
if (reconnects) { |
|
|
|
if (reconnects) { |
|
|
|
LOGNOTICE("%d clients flagged to reconnect from dead proxy %ld:%d", reconnects, |
|
|
|
LOGNOTICE("%d clients flagged to reconnect from dead proxy %ld:%d", reconnects, |
|
|
|
id, subid); |
|
|
|
id, subid); |
|
|
|
|
|
|
|
if (headroom < 42) |
|
|
|
|
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
} |
|
|
|
} |
|
|
|
if (headroom < 42) |
|
|
|
|
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void reassess_headroom(sdata_t *sdata, const proxy_t *proxy) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
stratum_instance_t *client, *tmpclient; |
|
|
|
|
|
|
|
proxy_t *subproxy, *tmp; |
|
|
|
|
|
|
|
int64_t headroom = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mutex_lock(&sdata->proxy_lock); |
|
|
|
|
|
|
|
HASH_ITER(sh, proxy->subproxies, subproxy, tmp) { |
|
|
|
|
|
|
|
if (subproxy->dead) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
headroom += subproxy->max_clients - subproxy->clients; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mutex_unlock(&sdata->proxy_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ck_rlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
HASH_ITER(hh, sdata->stratum_instances, client, tmpclient) { |
|
|
|
|
|
|
|
if (client->dropped) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
if (client->reconnect || client->proxyid != proxy->id) |
|
|
|
|
|
|
|
headroom--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (headroom < 1) |
|
|
|
|
|
|
|
generator_recruit(sdata->ckp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void update_subscribe(ckpool_t *ckp, const char *cmd) |
|
|
|
static void update_subscribe(ckpool_t *ckp, const char *cmd) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sdata_t *sdata = ckp->data, *dsdata; |
|
|
|
sdata_t *sdata = ckp->data, *dsdata; |
|
|
|
proxy_t *proxy, *old = NULL; |
|
|
|
proxy_t *proxy, *old = NULL; |
|
|
|
bool current = false; |
|
|
|
|
|
|
|
const char *buf; |
|
|
|
const char *buf; |
|
|
|
int64_t id = 0; |
|
|
|
int64_t id = 0; |
|
|
|
int subid = 0; |
|
|
|
int subid = 0; |
|
|
@ -1326,14 +1296,10 @@ static void update_subscribe(ckpool_t *ckp, const char *cmd) |
|
|
|
|
|
|
|
|
|
|
|
/* Is this a replacement proxy for the current one */ |
|
|
|
/* Is this a replacement proxy for the current one */ |
|
|
|
mutex_lock(&sdata->proxy_lock); |
|
|
|
mutex_lock(&sdata->proxy_lock); |
|
|
|
if (sdata->proxy && sdata->proxy->low_id == proxy->low_id && !proxy->subid) { |
|
|
|
if (sdata->proxy && sdata->proxy->low_id == proxy->low_id && !proxy->subid) |
|
|
|
current = true; |
|
|
|
|
|
|
|
sdata->proxy = proxy; |
|
|
|
sdata->proxy = proxy; |
|
|
|
} |
|
|
|
|
|
|
|
mutex_unlock(&sdata->proxy_lock); |
|
|
|
mutex_unlock(&sdata->proxy_lock); |
|
|
|
|
|
|
|
|
|
|
|
if (current) |
|
|
|
|
|
|
|
reassess_headroom(sdata, proxy); |
|
|
|
|
|
|
|
if (subid) { |
|
|
|
if (subid) { |
|
|
|
LOGINFO("Upstream pool %ld:%d extranonce2 length %d, max proxy clients %"PRId64, |
|
|
|
LOGINFO("Upstream pool %ld:%d extranonce2 length %d, max proxy clients %"PRId64, |
|
|
|
id, subid, proxy->nonce2len, proxy->max_clients); |
|
|
|
id, subid, proxy->nonce2len, proxy->max_clients); |
|
|
|