Clear pool work on a stratum reconnect message.
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
diff --git a/cgminer.c b/cgminer.c
index 2aed581..3e5b3c3 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3713,8 +3713,6 @@ static struct pool *priority_pool(int choice)
return ret;
}
-static void clear_pool_work(struct pool *pool);
-
/* Specifies whether we can switch to this pool or not. */
static bool pool_unusable(struct pool *pool)
{
@@ -5180,7 +5178,7 @@ void clear_stratum_shares(struct pool *pool)
}
}
-static void clear_pool_work(struct pool *pool)
+void clear_pool_work(struct pool *pool)
{
struct work *work, *tmp;
int cleared = 0;
@@ -5194,6 +5192,9 @@ static void clear_pool_work(struct pool *pool)
}
}
mutex_unlock(stgd_lock);
+
+ if (cleared)
+ applog(LOG_INFO, "Cleared %d work items due to stratum disconnect on pool %d", cleared, pool->pool_no);
}
static int cp_prio(void)
diff --git a/miner.h b/miner.h
index cab07c6..39a3cb8 100644
--- a/miner.h
+++ b/miner.h
@@ -1013,6 +1013,7 @@ extern pthread_mutex_t restart_lock;
extern pthread_cond_t restart_cond;
extern void clear_stratum_shares(struct pool *pool);
+extern void clear_pool_work(struct pool *pool);
extern void set_target(unsigned char *dest_target, double diff);
extern int restart_wait(struct thr_info *thr, unsigned int mstime);
diff --git a/util.c b/util.c
index 16aa8da..c30685a 100644
--- a/util.c
+++ b/util.c
@@ -1695,6 +1695,8 @@ static bool parse_reconnect(struct pool *pool, json_t *val)
applog(LOG_NOTICE, "Reconnect requested from pool %d to %s", pool->pool_no, address);
+ clear_pool_work(pool);
+
mutex_lock(&pool->stratum_lock);
__suspend_stratum(pool);
tmp = pool->sockaddr_url;