mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Keep track of when a longpoll has been sent for a pool and if the current pool is requesting work but has not sent a longpoll request, convert one of
the work items to a longpoll as we may have switched pools but still be using the longpoll from the previous pool.
This commit is contained in:
parent
4eca1aa05c
commit
39906718d2
@ -1572,9 +1572,9 @@ static inline struct pool *select_pool(bool lagging)
|
||||
|
||||
static bool get_upstream_work(struct work *work, bool lagging)
|
||||
{
|
||||
bool rc = false, req_longpoll = false;
|
||||
struct pool *pool;
|
||||
json_t *val = NULL;
|
||||
bool rc = false;
|
||||
int retries = 0;
|
||||
CURL *curl;
|
||||
|
||||
@ -1587,13 +1587,18 @@ static bool get_upstream_work(struct work *work, bool lagging)
|
||||
pool = select_pool(lagging);
|
||||
applog(LOG_DEBUG, "DBG: sending %s get RPC call: %s", pool->rpc_url, rpc_req);
|
||||
|
||||
/* If this is the current pool and supports longpoll but has not sent
|
||||
* a longpoll, send one now */
|
||||
if (unlikely(pool == current_pool() && pool->hdr_path && !pool->lp_sent))
|
||||
req_longpoll = true;
|
||||
|
||||
retry:
|
||||
/* A single failure response here might be reported as a dead pool and
|
||||
* there may be temporary denied messages etc. falsely reporting
|
||||
* failure so retry a few times before giving up */
|
||||
while (!val && retries++ < 3) {
|
||||
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
|
||||
false, false, &work->rolltime, pool, false);
|
||||
false, req_longpoll, &work->rolltime, pool, false);
|
||||
}
|
||||
if (unlikely(!val)) {
|
||||
applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");
|
||||
|
1
miner.h
1
miner.h
@ -537,6 +537,7 @@ struct pool {
|
||||
|
||||
char *hdr_path;
|
||||
char *lp_url;
|
||||
bool lp_sent;
|
||||
|
||||
unsigned int getwork_requested;
|
||||
unsigned int stale_shares;
|
||||
|
6
util.c
6
util.c
@ -301,10 +301,12 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
}
|
||||
if (longpoll) {
|
||||
pool->lp_sent = true;
|
||||
#ifdef CURL_HAS_SOCKOPT
|
||||
if (longpoll)
|
||||
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, json_rpc_call_sockopt_cb);
|
||||
#endif
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||
|
||||
if (opt_protocol)
|
||||
@ -350,6 +352,8 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
||||
}
|
||||
|
||||
rc = curl_easy_perform(curl);
|
||||
if (longpoll)
|
||||
pool->lp_sent = false;
|
||||
if (rc) {
|
||||
applog(LOG_INFO, "HTTP request failed: %s", curl_err_str);
|
||||
goto err_out;
|
||||
|
Loading…
Reference in New Issue
Block a user