|
@@ -4798,18 +4798,25 @@ static struct pool *_select_longpoll_pool(struct pool *, bool(*)(struct pool *))
|
|
|
static struct pool *select_balanced(struct pool *cp)
|
|
static struct pool *select_balanced(struct pool *cp)
|
|
|
{
|
|
{
|
|
|
int i, lowest = cp->shares;
|
|
int i, lowest = cp->shares;
|
|
|
- struct pool *ret = cp;
|
|
|
|
|
|
|
+ struct pool *ret = cp, *failover_pool = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < total_pools; i++) {
|
|
for (i = 0; i < total_pools; i++) {
|
|
|
struct pool *pool = pools[i];
|
|
struct pool *pool = pools[i];
|
|
|
|
|
|
|
|
if (pool_unworkable(pool))
|
|
if (pool_unworkable(pool))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
+ if (pool->failover_only)
|
|
|
|
|
+ {
|
|
|
|
|
+ BFGINIT(failover_pool, pool);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
if (pool->shares < lowest) {
|
|
if (pool->shares < lowest) {
|
|
|
lowest = pool->shares;
|
|
lowest = pool->shares;
|
|
|
ret = pool;
|
|
ret = pool;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (pool_unworkable(ret) && failover_pool)
|
|
|
|
|
+ ret = failover_pool;
|
|
|
|
|
|
|
|
ret->shares++;
|
|
ret->shares++;
|
|
|
return ret;
|
|
return ret;
|
|
@@ -4834,6 +4841,8 @@ static inline struct pool *select_pool(bool lagging)
|
|
|
retry:
|
|
retry:
|
|
|
if (pool_strategy == POOL_BALANCE) {
|
|
if (pool_strategy == POOL_BALANCE) {
|
|
|
pool = select_balanced(cp);
|
|
pool = select_balanced(cp);
|
|
|
|
|
+ if (pool_unworkable(pool))
|
|
|
|
|
+ goto simple_failover;
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -4877,6 +4886,7 @@ retry:
|
|
|
rotating_pool = 0;
|
|
rotating_pool = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+simple_failover:
|
|
|
/* If there are no alive pools with quota, choose according to
|
|
/* If there are no alive pools with quota, choose according to
|
|
|
* priority. */
|
|
* priority. */
|
|
|
if (!pool) {
|
|
if (!pool) {
|
|
@@ -6320,7 +6330,7 @@ static bool pool_unusable(struct pool *pool)
|
|
|
|
|
|
|
|
void switch_pools(struct pool *selected)
|
|
void switch_pools(struct pool *selected)
|
|
|
{
|
|
{
|
|
|
- struct pool *pool, *last_pool;
|
|
|
|
|
|
|
+ struct pool *pool, *last_pool, *failover_pool = NULL;
|
|
|
int i, pool_no, next_pool;
|
|
int i, pool_no, next_pool;
|
|
|
|
|
|
|
|
cg_wlock(&control_lock);
|
|
cg_wlock(&control_lock);
|
|
@@ -6368,6 +6378,11 @@ void switch_pools(struct pool *selected)
|
|
|
pool = pools[next_pool];
|
|
pool = pools[next_pool];
|
|
|
if (pool_unusable(pool))
|
|
if (pool_unusable(pool))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
+ if (pool->failover_only)
|
|
|
|
|
+ {
|
|
|
|
|
+ BFGINIT(failover_pool, pool);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
pool_no = next_pool;
|
|
pool_no = next_pool;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -6376,8 +6391,10 @@ void switch_pools(struct pool *selected)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- currentpool = pools[pool_no];
|
|
|
|
|
- pool = currentpool;
|
|
|
|
|
|
|
+ pool = pools[pool_no];
|
|
|
|
|
+ if (pool_unusable(pool) && failover_pool)
|
|
|
|
|
+ pool = failover_pool;
|
|
|
|
|
+ currentpool = pool;
|
|
|
mutex_lock(&lp_lock);
|
|
mutex_lock(&lp_lock);
|
|
|
pthread_cond_broadcast(&lp_cond);
|
|
pthread_cond_broadcast(&lp_cond);
|
|
|
mutex_unlock(&lp_lock);
|
|
mutex_unlock(&lp_lock);
|
|
@@ -7187,12 +7204,15 @@ updated:
|
|
|
|
|
|
|
|
if (pool == current_pool())
|
|
if (pool == current_pool())
|
|
|
wattron(logwin, A_BOLD);
|
|
wattron(logwin, A_BOLD);
|
|
|
- if (pool->enabled != POOL_ENABLED)
|
|
|
|
|
|
|
+ if (pool->enabled != POOL_ENABLED || pool->failover_only)
|
|
|
wattron(logwin, A_DIM);
|
|
wattron(logwin, A_DIM);
|
|
|
wlogprint("%d: ", pool->prio);
|
|
wlogprint("%d: ", pool->prio);
|
|
|
switch (pool->enabled) {
|
|
switch (pool->enabled) {
|
|
|
case POOL_ENABLED:
|
|
case POOL_ENABLED:
|
|
|
- wlogprint("Enabled ");
|
|
|
|
|
|
|
+ if (pool->failover_only)
|
|
|
|
|
+ wlogprint("Failover ");
|
|
|
|
|
+ else
|
|
|
|
|
+ wlogprint("Enabled ");
|
|
|
break;
|
|
break;
|
|
|
case POOL_DISABLED:
|
|
case POOL_DISABLED:
|
|
|
wlogprint("Disabled ");
|
|
wlogprint("Disabled ");
|
|
@@ -7258,6 +7278,7 @@ retry:
|
|
|
goto retry;
|
|
goto retry;
|
|
|
}
|
|
}
|
|
|
pool = pools[selected];
|
|
pool = pools[selected];
|
|
|
|
|
+ pool->failover_only = false;
|
|
|
enable_pool(pool);
|
|
enable_pool(pool);
|
|
|
switch_pools(pool);
|
|
switch_pools(pool);
|
|
|
goto updated;
|
|
goto updated;
|
|
@@ -7283,6 +7304,7 @@ retry:
|
|
|
goto retry;
|
|
goto retry;
|
|
|
}
|
|
}
|
|
|
pool = pools[selected];
|
|
pool = pools[selected];
|
|
|
|
|
+ pool->failover_only = false;
|
|
|
enable_pool(pool);
|
|
enable_pool(pool);
|
|
|
if (pool->prio < current_pool()->prio)
|
|
if (pool->prio < current_pool()->prio)
|
|
|
switch_pools(pool);
|
|
switch_pools(pool);
|