From 98676763b96f938d67adbfe54bf776c1a353de6b Mon Sep 17 00:00:00 2001 From: elbandi Date: Sun, 27 Apr 2014 17:17:49 +0200 Subject: [PATCH] Set the pool idle and switch pool, if need --- miner.h | 1 + sgminer.c | 10 ++++++++++ util.c | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/miner.h b/miner.h index 7db088fd..2c97f38f 100644 --- a/miner.h +++ b/miner.h @@ -1418,6 +1418,7 @@ extern bool log_curses_only(int prio, const char *datetime, const char *str); extern void clear_logwin(void); extern void logwin_update(void); extern bool pool_tclear(struct pool *pool, bool *var); +extern void pool_failed(struct pool *pool); extern struct thread_q *tq_new(void); extern void tq_free(struct thread_q *tq); extern bool tq_push(struct thread_q *tq, void *data); diff --git a/sgminer.c b/sgminer.c index 5d71441e..4d039933 100644 --- a/sgminer.c +++ b/sgminer.c @@ -3605,6 +3605,16 @@ struct work *copy_work_noffset(struct work *base_work, int noffset) return work; } +void pool_failed(struct pool *pool) +{ + if (!pool_tset(pool, &pool->idle)) { + cgtime(&pool->tv_idle); + if (pool == current_pool()) { + switch_pools(NULL); + } + } +} + static void pool_died(struct pool *pool) { if (!pool_tset(pool, &pool->idle)) { diff --git a/util.c b/util.c index 128a0479..873d8e59 100644 --- a/util.c +++ b/util.c @@ -1712,8 +1712,10 @@ static bool parse_reconnect(struct pool *pool, json_t *val) free(tmp); mutex_unlock(&pool->stratum_lock); - if (!restart_stratum(pool)) + if (!restart_stratum(pool)) { + pool_failed(pool); return false; + } return true; }