From 1468feb0d30c3e3ccafbb3337bda5f8ab90fce22 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Mar 2013 18:13:25 +1100 Subject: [PATCH] Find the first usable pool in preference to the current pool in select_pool for work. --- cgminer.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/cgminer.c b/cgminer.c index c0a0ccd2..0b5f20ef 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2618,11 +2618,23 @@ static struct pool *select_balanced(struct pool *cp) return ret; } +static bool pool_unusable(struct pool *pool) +{ + if (pool->idle) + return true; + if (pool->enabled != POOL_ENABLED) + return true; + if (pool->has_stratum && !pool->stratum_active) + return true; + return false; +} + /* Select any active pool in a rotating fashion when loadbalance is chosen */ static inline struct pool *select_pool(bool lagging) { static int rotating_pool = 0; struct pool *pool, *cp; + int tested; cp = current_pool(); @@ -2634,14 +2646,19 @@ static inline struct pool *select_pool(bool lagging) else pool = NULL; - while (!pool) { + /* Try to find the first pool in the rotation that is usable */ + tested = 0; + while (!pool && tested++ < total_pools) { if (++rotating_pool >= total_pools) rotating_pool = 0; pool = pools[rotating_pool]; - if ((!pool->idle && pool->enabled == POOL_ENABLED) || pool == cp) + if (!pool_unusable(pool)) break; pool = NULL; } + /* If still nothing is usable, use the current pool */ + if (!pool) + pool = cp; return pool; } @@ -3358,17 +3375,6 @@ static struct pool *priority_pool(int choice) static void clear_pool_work(struct pool *pool); -static bool pool_unusable(struct pool *pool) -{ - if (pool->idle) - return true; - if (pool->enabled != POOL_ENABLED) - return true; - if (pool->has_stratum && !pool->stratum_active) - return true; - return false; -} - void switch_pools(struct pool *selected) { struct pool *pool, *last_pool;