|
|
@@ -2618,23 +2618,11 @@ 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();
|
|
|
|
|
|
@@ -2646,19 +2634,14 @@ static inline struct pool *select_pool(bool lagging)
|
|
|
else
|
|
|
pool = NULL;
|
|
|
|
|
|
- /* Try to find the first pool in the rotation that is usable */
|
|
|
- tested = 0;
|
|
|
- while (!pool && tested++ < total_pools) {
|
|
|
+ while (!pool) {
|
|
|
if (++rotating_pool >= total_pools)
|
|
|
rotating_pool = 0;
|
|
|
pool = pools[rotating_pool];
|
|
|
- if (!pool_unusable(pool))
|
|
|
+ if ((!pool->idle && pool->enabled == POOL_ENABLED) || pool == cp)
|
|
|
break;
|
|
|
pool = NULL;
|
|
|
}
|
|
|
- /* If still nothing is usable, use the current pool */
|
|
|
- if (!pool)
|
|
|
- pool = cp;
|
|
|
|
|
|
return pool;
|
|
|
}
|
|
|
@@ -3403,10 +3386,10 @@ void switch_pools(struct pool *selected)
|
|
|
case POOL_LOADBALANCE:
|
|
|
for (i = 0; i < total_pools; i++) {
|
|
|
pool = priority_pool(i);
|
|
|
- if (pool_unusable(pool) && pool != selected)
|
|
|
- continue;
|
|
|
- pool_no = pool->pool_no;
|
|
|
- break;
|
|
|
+ if (!pool->idle && pool->enabled == POOL_ENABLED) {
|
|
|
+ pool_no = pool->pool_no;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
/* Both of these simply increment and cycle */
|
|
|
@@ -3423,10 +3406,10 @@ void switch_pools(struct pool *selected)
|
|
|
if (next_pool >= total_pools)
|
|
|
next_pool = 0;
|
|
|
pool = pools[next_pool];
|
|
|
- if (pool_unusable(pool) && pool != selected)
|
|
|
- continue;
|
|
|
- pool_no = next_pool;
|
|
|
- break;
|
|
|
+ if (!pool->idle && pool->enabled == POOL_ENABLED) {
|
|
|
+ pool_no = next_pool;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
default:
|