From cc2aa215a8301bb10db9ce3cb1e5bd9ca0cb89fe Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 23 Jan 2014 22:02:58 +1100 Subject: [PATCH] Clear pool work on a stratum reconnect message. --- miner.h | 1 + sgminer.c | 7 ++++--- util.c | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/miner.h b/miner.h index 8a55776f..44d5fba3 100644 --- a/miner.h +++ b/miner.h @@ -1023,6 +1023,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/sgminer.c b/sgminer.c index 60b709aa..c0e49494 100644 --- a/sgminer.c +++ b/sgminer.c @@ -3598,8 +3598,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) { @@ -5138,7 +5136,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; @@ -5152,6 +5150,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/util.c b/util.c index c146bd0f..c4e883c2 100644 --- a/util.c +++ b/util.c @@ -1691,6 +1691,8 @@ static bool parse_reconnect(struct pool *pool, json_t *val) applog(LOG_NOTICE, "Reconnect requested from %s to %s", pool->poolname, address); + clear_pool_work(pool); + mutex_lock(&pool->stratum_lock); __suspend_stratum(pool); tmp = pool->sockaddr_url;