Load balancing puts more into the current pool if there are disabled pools. Fix.
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
diff --git a/main.c b/main.c
index 003f271..09d46f1 100644
--- a/main.c
+++ b/main.c
@@ -929,22 +929,29 @@ out_nofree:
static const char *rpc_req =
"{\"method\": \"getwork\", \"params\": [], \"id\":0}\r\n";
-static int rotating_pool;
-
/* Select any active pool in a rotating fashion when loadbalance is chosen */
static inline struct pool *select_pool(void)
{
- if (pool_strategy == POOL_LOADBALANCE) {
- struct pool *pool;
+ static int rotating_pool;
+ struct pool *pool, *cp;
+
+ cp = current_pool();
+
+ if (pool_strategy != POOL_LOADBALANCE)
+ pool = cp;
+ else
+ pool = NULL;
- rotating_pool++;
- if (rotating_pool >= total_pools)
+ while (!pool) {
+ if (++rotating_pool >= total_pools)
rotating_pool = 0;
pool = pools[rotating_pool];
- if (!pool->idle && pool->enabled)
- return pools[rotating_pool];
+ if ((!pool->idle && pool->enabled) || pool == cp)
+ break;
+ pool = NULL;
}
- return current_pool();
+
+ return pool;
}
static bool get_upstream_work(struct work *work)