Test for sequential getwork failures on a pool that might actually be up but failing to deliver work as we may end up hammering it repeatedly by mistake.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
diff --git a/cgminer.c b/cgminer.c
index 90bc4a8..7645ff2 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2476,6 +2476,15 @@ out:
static bool queue_request(void);
+static void pool_died(struct pool *pool)
+{
+ if (!pool_tset(pool, &pool->idle)) {
+ applog(LOG_WARNING, "Pool %d %s not responding!", pool->pool_no, pool->rpc_url);
+ gettimeofday(&pool->tv_idle, NULL);
+ switch_pools(NULL);
+ }
+}
+
static void *get_work_thread(void *userdata)
{
struct workio_cmd *wc = (struct workio_cmd *)userdata;
@@ -2508,13 +2517,17 @@ static void *get_work_thread(void *userdata)
/* obtain new work from bitcoin via JSON-RPC */
if (!get_upstream_work(ret_work, ce->curl)) {
- /* pause, then restart work-request loop */
applog(LOG_DEBUG, "json_rpc_call failed on get work, retrying");
dec_queued(pool);
+ /* Make sure the pool just hasn't stopped serving
+ * requests but is up as we'll keep hammering it */
+ if (++pool->seq_getfails > mining_threads + opt_queue)
+ pool_died(pool);
queue_request();
free_work(ret_work);
goto out;
}
+ pool->seq_getfails = 0;
ret_work->queued = true;
}
@@ -3998,15 +4011,6 @@ out:
return ret;
}
-static void pool_died(struct pool *pool)
-{
- if (!pool_tset(pool, &pool->idle)) {
- applog(LOG_WARNING, "Pool %d %s not responding!", pool->pool_no, pool->rpc_url);
- gettimeofday(&pool->tv_idle, NULL);
- switch_pools(NULL);
- }
-}
-
static inline int cp_prio(void)
{
int prio;
diff --git a/miner.h b/miner.h
index 8d85475..ede389a 100644
--- a/miner.h
+++ b/miner.h
@@ -748,6 +748,7 @@ struct pool {
int prio;
int accepted, rejected;
int seq_rejects;
+ int seq_getfails;
int solved;
int diff1;