Merge pull request #595 from Elbandi/idlebugfix Mark pool as idle if stratum restart is failed
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
diff --git a/cgminer.c b/cgminer.c
index 46e4aa7..63f8201 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4152,6 +4152,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)) {
@@ -6102,6 +6112,7 @@ static void *stratum_rthread(void *userdata)
if (!restart_stratum(pool)) {
pool_died(pool);
while (!restart_stratum(pool)) {
+ pool_failed(pool);
if (pool->removed)
goto out;
cgsleep_ms(30000);
@@ -6142,6 +6153,7 @@ static void *stratum_rthread(void *userdata)
pool_died(pool);
while (!restart_stratum(pool)) {
+ pool_failed(pool);
if (pool->removed)
goto out;
cgsleep_ms(30000);
diff --git a/miner.h b/miner.h
index 7b79010..ffa20ee 100644
--- a/miner.h
+++ b/miner.h
@@ -1454,6 +1454,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/util.c b/util.c
index 69fd1e1..0317adc 100644
--- a/util.c
+++ b/util.c
@@ -1900,8 +1900,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;
}