|
|
@ -112,9 +112,6 @@ struct proxy_instance { |
|
|
|
int64_t recruit; /* No of recruiting requests in progress */ |
|
|
|
int64_t recruit; /* No of recruiting requests in progress */ |
|
|
|
bool alive; |
|
|
|
bool alive; |
|
|
|
|
|
|
|
|
|
|
|
mutex_t notify_lock; |
|
|
|
|
|
|
|
notify_instance_t *notify_instances; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pthread_t pth_precv; |
|
|
|
pthread_t pth_precv; |
|
|
|
|
|
|
|
|
|
|
|
ckmsgq_t *passsends; // passthrough sends
|
|
|
|
ckmsgq_t *passsends; // passthrough sends
|
|
|
@ -147,6 +144,9 @@ struct generator_data { |
|
|
|
|
|
|
|
|
|
|
|
stratum_msg_t *psends; |
|
|
|
stratum_msg_t *psends; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mutex_t notify_lock; |
|
|
|
|
|
|
|
notify_instance_t *notify_instances; |
|
|
|
|
|
|
|
|
|
|
|
mutex_t share_lock; |
|
|
|
mutex_t share_lock; |
|
|
|
share_msg_t *shares; |
|
|
|
share_msg_t *shares; |
|
|
|
int64_t share_id; |
|
|
|
int64_t share_id; |
|
|
@ -780,7 +780,6 @@ static void reconnect_generator(const ckpool_t *ckp) |
|
|
|
static bool parse_notify(ckpool_t *ckp, proxy_instance_t *proxi, json_t *val) |
|
|
|
static bool parse_notify(ckpool_t *ckp, proxy_instance_t *proxi, json_t *val) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const char *prev_hash, *bbversion, *nbit, *ntime; |
|
|
|
const char *prev_hash, *bbversion, *nbit, *ntime; |
|
|
|
proxy_instance_t *proxy = proxi->parent; |
|
|
|
|
|
|
|
gdata_t *gdata = proxi->ckp->data; |
|
|
|
gdata_t *gdata = proxi->ckp->data; |
|
|
|
char *coinbase1, *coinbase2; |
|
|
|
char *coinbase1, *coinbase2; |
|
|
|
const char *jobidbuf; |
|
|
|
const char *jobidbuf; |
|
|
@ -844,10 +843,10 @@ static bool parse_notify(ckpool_t *ckp, proxy_instance_t *proxi, json_t *val) |
|
|
|
ni->notify_time = time(NULL); |
|
|
|
ni->notify_time = time(NULL); |
|
|
|
|
|
|
|
|
|
|
|
/* Add the notify instance to the parent proxy list, not the subproxy */ |
|
|
|
/* Add the notify instance to the parent proxy list, not the subproxy */ |
|
|
|
mutex_lock(&proxy->notify_lock); |
|
|
|
mutex_lock(&gdata->notify_lock); |
|
|
|
ni->id = gdata->proxy_notify_id++; |
|
|
|
ni->id = gdata->proxy_notify_id++; |
|
|
|
HASH_ADD_INT(proxy->notify_instances, id, ni); |
|
|
|
HASH_ADD_INT(gdata->notify_instances, id, ni); |
|
|
|
mutex_unlock(&proxy->notify_lock); |
|
|
|
mutex_unlock(&gdata->notify_lock); |
|
|
|
|
|
|
|
|
|
|
|
send_notify(ckp, proxi, ni); |
|
|
|
send_notify(ckp, proxi, ni); |
|
|
|
out: |
|
|
|
out: |
|
|
@ -1608,11 +1607,11 @@ static void *proxy_send(void *arg) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mutex_lock(&proxy->notify_lock); |
|
|
|
mutex_lock(&gdata->notify_lock); |
|
|
|
HASH_FIND_INT(proxy->notify_instances, &id, ni); |
|
|
|
HASH_FIND_INT(gdata->notify_instances, &id, ni); |
|
|
|
if (ni) |
|
|
|
if (ni) |
|
|
|
jobid = json_copy(ni->jobid); |
|
|
|
jobid = json_copy(ni->jobid); |
|
|
|
mutex_unlock(&proxy->notify_lock); |
|
|
|
mutex_unlock(&gdata->notify_lock); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!jobid)) { |
|
|
|
if (unlikely(!jobid)) { |
|
|
|
stratifier_reconnect_client(ckp, client_id); |
|
|
|
stratifier_reconnect_client(ckp, client_id); |
|
|
@ -1944,16 +1943,16 @@ static void *proxy_recv(void *arg) |
|
|
|
now = time(NULL); |
|
|
|
now = time(NULL); |
|
|
|
|
|
|
|
|
|
|
|
/* Age old notifications older than 10 mins old */ |
|
|
|
/* Age old notifications older than 10 mins old */ |
|
|
|
mutex_lock(&proxi->notify_lock); |
|
|
|
mutex_lock(&gdata->notify_lock); |
|
|
|
HASH_ITER(hh, proxi->notify_instances, ni, tmp) { |
|
|
|
HASH_ITER(hh, gdata->notify_instances, ni, tmp) { |
|
|
|
if (HASH_COUNT(proxi->notify_instances) < 3) |
|
|
|
if (HASH_COUNT(gdata->notify_instances) < 3) |
|
|
|
break; |
|
|
|
break; |
|
|
|
if (ni->notify_time < now - 600) { |
|
|
|
if (ni->notify_time < now - 600) { |
|
|
|
HASH_DEL(proxi->notify_instances, ni); |
|
|
|
HASH_DEL(gdata->notify_instances, ni); |
|
|
|
clear_notify(ni); |
|
|
|
clear_notify(ni); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mutex_unlock(&proxi->notify_lock); |
|
|
|
mutex_unlock(&gdata->notify_lock); |
|
|
|
|
|
|
|
|
|
|
|
/* Similary with shares older than 2 mins without response */ |
|
|
|
/* Similary with shares older than 2 mins without response */ |
|
|
|
mutex_lock(&gdata->share_lock); |
|
|
|
mutex_lock(&gdata->share_lock); |
|
|
@ -2014,7 +2013,7 @@ static void *userproxy_recv(void *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (42) { |
|
|
|
while (42) { |
|
|
|
proxy_instance_t *proxy, *tmpproxy, *parent; |
|
|
|
proxy_instance_t *proxy, *tmpproxy; |
|
|
|
share_msg_t *share, *tmpshare; |
|
|
|
share_msg_t *share, *tmpshare; |
|
|
|
notify_instance_t *ni, *tmp; |
|
|
|
notify_instance_t *ni, *tmp; |
|
|
|
connsock_t *cs; |
|
|
|
connsock_t *cs; |
|
|
@ -2046,18 +2045,17 @@ static void *userproxy_recv(void *arg) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
now = time(NULL); |
|
|
|
now = time(NULL); |
|
|
|
parent = proxy->parent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mutex_lock(&parent->notify_lock); |
|
|
|
mutex_lock(&gdata->notify_lock); |
|
|
|
HASH_ITER(hh, parent->notify_instances, ni, tmp) { |
|
|
|
HASH_ITER(hh, gdata->notify_instances, ni, tmp) { |
|
|
|
if (HASH_COUNT(parent->notify_instances) < 3) |
|
|
|
if (HASH_COUNT(gdata->notify_instances) < 3) |
|
|
|
break; |
|
|
|
break; |
|
|
|
if (ni->notify_time < now - 600) { |
|
|
|
if (ni->notify_time < now - 600) { |
|
|
|
HASH_DEL(parent->notify_instances, ni); |
|
|
|
HASH_DEL(gdata->notify_instances, ni); |
|
|
|
clear_notify(ni); |
|
|
|
clear_notify(ni); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mutex_unlock(&parent->notify_lock); |
|
|
|
mutex_unlock(&gdata->notify_lock); |
|
|
|
|
|
|
|
|
|
|
|
/* Similary with shares older than 2 mins without response */ |
|
|
|
/* Similary with shares older than 2 mins without response */ |
|
|
|
mutex_lock(&gdata->share_lock); |
|
|
|
mutex_lock(&gdata->share_lock); |
|
|
@ -2210,7 +2208,6 @@ static proxy_instance_t *__add_userproxy(ckpool_t *ckp, gdata_t *gdata, const in |
|
|
|
proxy->auth = auth; |
|
|
|
proxy->auth = auth; |
|
|
|
proxy->pass = pass; |
|
|
|
proxy->pass = pass; |
|
|
|
proxy->ckp = proxy->cs.ckp = ckp; |
|
|
|
proxy->ckp = proxy->cs.ckp = ckp; |
|
|
|
mutex_init(&proxy->notify_lock); |
|
|
|
|
|
|
|
HASH_ADD_INT(gdata->proxies, id, proxy); |
|
|
|
HASH_ADD_INT(gdata->proxies, id, proxy); |
|
|
|
return proxy; |
|
|
|
return proxy; |
|
|
|
} |
|
|
|
} |
|
|
@ -2495,7 +2492,6 @@ static proxy_instance_t *__add_proxy(ckpool_t *ckp, gdata_t *gdata, const int id |
|
|
|
proxy->auth = strdup(ckp->proxyauth[id]); |
|
|
|
proxy->auth = strdup(ckp->proxyauth[id]); |
|
|
|
proxy->pass = strdup(ckp->proxypass[id]); |
|
|
|
proxy->pass = strdup(ckp->proxypass[id]); |
|
|
|
proxy->ckp = proxy->cs.ckp = ckp; |
|
|
|
proxy->ckp = proxy->cs.ckp = ckp; |
|
|
|
mutex_init(&proxy->notify_lock); |
|
|
|
|
|
|
|
HASH_ADD_INT(gdata->proxies, id, proxy); |
|
|
|
HASH_ADD_INT(gdata->proxies, id, proxy); |
|
|
|
proxy->global = true; |
|
|
|
proxy->global = true; |
|
|
|
return proxy; |
|
|
|
return proxy; |
|
|
@ -2508,6 +2504,7 @@ static int proxy_mode(ckpool_t *ckp, proc_instance_t *pi) |
|
|
|
int i, ret; |
|
|
|
int i, ret; |
|
|
|
|
|
|
|
|
|
|
|
mutex_init(&gdata->lock); |
|
|
|
mutex_init(&gdata->lock); |
|
|
|
|
|
|
|
mutex_init(&gdata->notify_lock); |
|
|
|
mutex_init(&gdata->share_lock); |
|
|
|
mutex_init(&gdata->share_lock); |
|
|
|
|
|
|
|
|
|
|
|
/* Create all our proxy structures and pointers */ |
|
|
|
/* Create all our proxy structures and pointers */ |
|
|
|