|
@@ -2176,7 +2176,6 @@ static bool get_upstream_work(struct work *work, CURL *curl)
|
|
|
struct timeval tv_start, tv_end, tv_elapsed;
|
|
struct timeval tv_start, tv_end, tv_elapsed;
|
|
|
json_t *val = NULL;
|
|
json_t *val = NULL;
|
|
|
bool rc = false;
|
|
bool rc = false;
|
|
|
- int retries = 0;
|
|
|
|
|
char *url;
|
|
char *url;
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "DBG: sending %s get RPC call: %s", pool->rpc_url, rpc_req);
|
|
applog(LOG_DEBUG, "DBG: sending %s get RPC call: %s", pool->rpc_url, rpc_req);
|
|
@@ -2184,23 +2183,17 @@ static bool get_upstream_work(struct work *work, CURL *curl)
|
|
|
url = pool->rpc_url;
|
|
url = pool->rpc_url;
|
|
|
|
|
|
|
|
gettimeofday(&tv_start, NULL);
|
|
gettimeofday(&tv_start, NULL);
|
|
|
-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) {
|
|
|
|
|
- pool_stats->getwork_attempts++;
|
|
|
|
|
- val = json_rpc_call(curl, url, pool->rpc_userpass, rpc_req,
|
|
|
|
|
- false, false, &work->rolltime, pool, false);
|
|
|
|
|
- }
|
|
|
|
|
- if (unlikely(!val)) {
|
|
|
|
|
- applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");
|
|
|
|
|
- goto out;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- rc = work_decode(json_object_get(val, "result"), work);
|
|
|
|
|
- if (!rc && retries < 3)
|
|
|
|
|
- goto retry;
|
|
|
|
|
|
|
+ val = json_rpc_call(curl, url, pool->rpc_userpass, rpc_req, false,
|
|
|
|
|
+ false, &work->rolltime, pool, false);
|
|
|
|
|
+ pool_stats->getwork_attempts++;
|
|
|
|
|
+
|
|
|
|
|
+ if (likely(val)) {
|
|
|
|
|
+ rc = work_decode(json_object_get(val, "result"), work);
|
|
|
|
|
+ if (unlikely(!rc))
|
|
|
|
|
+ applog(LOG_DEBUG, "Failed to decode work in get_upstream_work");
|
|
|
|
|
+ } else
|
|
|
|
|
+ applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");
|
|
|
|
|
|
|
|
gettimeofday(&tv_end, NULL);
|
|
gettimeofday(&tv_end, NULL);
|
|
|
timersub(&tv_end, &tv_start, &tv_elapsed);
|
|
timersub(&tv_end, &tv_start, &tv_elapsed);
|
|
@@ -2223,8 +2216,8 @@ retry:
|
|
|
total_getworks++;
|
|
total_getworks++;
|
|
|
pool->getwork_requested++;
|
|
pool->getwork_requested++;
|
|
|
|
|
|
|
|
- json_decref(val);
|
|
|
|
|
-out:
|
|
|
|
|
|
|
+ if (likely(val))
|
|
|
|
|
+ json_decref(val);
|
|
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
|
}
|
|
}
|
|
@@ -4434,13 +4427,12 @@ static struct work *clone_work(struct work *work)
|
|
|
return work;
|
|
return work;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static bool get_work(struct work *work, struct thr_info *thr, const int thr_id)
|
|
|
|
|
|
|
+static void get_work(struct work *work, struct thr_info *thr, const int thr_id)
|
|
|
{
|
|
{
|
|
|
struct timespec abstime = {0, 0};
|
|
struct timespec abstime = {0, 0};
|
|
|
struct work *work_heap;
|
|
struct work *work_heap;
|
|
|
struct timeval now;
|
|
struct timeval now;
|
|
|
struct pool *pool;
|
|
struct pool *pool;
|
|
|
- bool ret = false;
|
|
|
|
|
|
|
|
|
|
/* Tell the watchdog thread this thread is waiting on getwork and
|
|
/* Tell the watchdog thread this thread is waiting on getwork and
|
|
|
* should not be restarted */
|
|
* should not be restarted */
|
|
@@ -4448,17 +4440,14 @@ static bool get_work(struct work *work, struct thr_info *thr, const int thr_id)
|
|
|
|
|
|
|
|
if (opt_benchmark) {
|
|
if (opt_benchmark) {
|
|
|
get_benchmark_work(work);
|
|
get_benchmark_work(work);
|
|
|
- thread_reportin(thr);
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
retry:
|
|
retry:
|
|
|
pool = current_pool();
|
|
pool = current_pool();
|
|
|
|
|
|
|
|
- if (reuse_work(work)) {
|
|
|
|
|
- ret = true;
|
|
|
|
|
|
|
+ if (reuse_work(work))
|
|
|
goto out;
|
|
goto out;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
if (!pool->lagging && !total_staged() && global_queued() >= mining_threads + opt_queue) {
|
|
if (!pool->lagging && !total_staged() && global_queued() >= mining_threads + opt_queue) {
|
|
|
struct cgpu_info *cgpu = thr->cgpu;
|
|
struct cgpu_info *cgpu = thr->cgpu;
|
|
@@ -4515,21 +4504,10 @@ keepwaiting:
|
|
|
memcpy(work, work_heap, sizeof(struct work));
|
|
memcpy(work, work_heap, sizeof(struct work));
|
|
|
free_work(work_heap);
|
|
free_work(work_heap);
|
|
|
|
|
|
|
|
- ret = true;
|
|
|
|
|
out:
|
|
out:
|
|
|
- if (unlikely(ret == false)) {
|
|
|
|
|
- applog(LOG_DEBUG, "Retrying after %d seconds", fail_pause);
|
|
|
|
|
- sleep(fail_pause);
|
|
|
|
|
- fail_pause += opt_fail_pause;
|
|
|
|
|
- goto retry;
|
|
|
|
|
- }
|
|
|
|
|
- fail_pause = opt_fail_pause;
|
|
|
|
|
-
|
|
|
|
|
work->thr_id = thr_id;
|
|
work->thr_id = thr_id;
|
|
|
thread_reportin(thr);
|
|
thread_reportin(thr);
|
|
|
- if (ret)
|
|
|
|
|
- work->mined = true;
|
|
|
|
|
- return ret;
|
|
|
|
|
|
|
+ work->mined = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool submit_work_sync(struct thr_info *thr, const struct work *work_in)
|
|
bool submit_work_sync(struct thr_info *thr, const struct work *work_in)
|
|
@@ -4692,11 +4670,8 @@ void *miner_thread(void *userdata)
|
|
|
mythr->work_restart = false;
|
|
mythr->work_restart = false;
|
|
|
if (api->free_work && likely(work->pool))
|
|
if (api->free_work && likely(work->pool))
|
|
|
api->free_work(mythr, work);
|
|
api->free_work(mythr, work);
|
|
|
- if (unlikely(!get_work(work, mythr, thr_id))) {
|
|
|
|
|
- applog(LOG_ERR, "work retrieval failed, exiting "
|
|
|
|
|
- "mining thread %d", thr_id);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ get_work(work, mythr, thr_id);
|
|
|
|
|
+
|
|
|
gettimeofday(&tv_workstart, NULL);
|
|
gettimeofday(&tv_workstart, NULL);
|
|
|
work->blk.nonce = 0;
|
|
work->blk.nonce = 0;
|
|
|
cgpu->max_hashes = 0;
|
|
cgpu->max_hashes = 0;
|