1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-23 13:04:29 +00:00

Find the first usable pool in preference to the current pool in select_pool for work.

This commit is contained in:
Con Kolivas 2013-03-07 18:13:25 +11:00
parent ade8c6c79c
commit 1468feb0d3

View File

@ -2618,11 +2618,23 @@ static struct pool *select_balanced(struct pool *cp)
return ret; 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 */ /* Select any active pool in a rotating fashion when loadbalance is chosen */
static inline struct pool *select_pool(bool lagging) static inline struct pool *select_pool(bool lagging)
{ {
static int rotating_pool = 0; static int rotating_pool = 0;
struct pool *pool, *cp; struct pool *pool, *cp;
int tested;
cp = current_pool(); cp = current_pool();
@ -2634,14 +2646,19 @@ static inline struct pool *select_pool(bool lagging)
else else
pool = NULL; 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) if (++rotating_pool >= total_pools)
rotating_pool = 0; rotating_pool = 0;
pool = pools[rotating_pool]; pool = pools[rotating_pool];
if ((!pool->idle && pool->enabled == POOL_ENABLED) || pool == cp) if (!pool_unusable(pool))
break; break;
pool = NULL; pool = NULL;
} }
/* If still nothing is usable, use the current pool */
if (!pool)
pool = cp;
return pool; return pool;
} }
@ -3358,17 +3375,6 @@ static struct pool *priority_pool(int choice)
static void clear_pool_work(struct pool *pool); 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) void switch_pools(struct pool *selected)
{ {
struct pool *pool, *last_pool; struct pool *pool, *last_pool;