Keep a connection open on higher priority stratum pools to fail back to them.
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 44 45 46 47 48 49 50 51 52 53 54
diff --git a/cgminer.c b/cgminer.c
index e1d700d..c3a019c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4802,6 +4802,16 @@ static void clear_pool_work(struct pool *pool)
mutex_unlock(stgd_lock);
}
+static int cp_prio(void)
+{
+ int prio;
+
+ mutex_lock(&control_lock);
+ prio = currentpool->prio;
+ mutex_unlock(&control_lock);
+ return prio;
+}
+
/* We only need to maintain a secondary pool connection when we need the
* capacity to get work from the backup pools while still on the primary */
static bool cnx_needed(struct pool *pool)
@@ -4829,6 +4839,11 @@ static bool cnx_needed(struct pool *pool)
* connection open. */
if (pool->sshares)
return true;
+ /* If the pool has only just come to life and is higher priority than
+ * the current pool keep the connection open so we can fail back to
+ * it. */
+ if (pool_strategy == POOL_FAILOVER && pool->prio < cp_prio())
+ return true;
return false;
}
@@ -5173,19 +5188,9 @@ out:
return ret;
}
-static inline int cp_prio(void)
-{
- int prio;
-
- mutex_lock(&control_lock);
- prio = currentpool->prio;
- mutex_unlock(&control_lock);
- return prio;
-}
-
static void pool_resus(struct pool *pool)
{
- if (pool->prio < cp_prio() && pool_strategy == POOL_FAILOVER) {
+ if (pool_strategy == POOL_FAILOVER && pool->prio < cp_prio()) {
applog(LOG_WARNING, "Pool %d %s alive", pool->pool_no, pool->rpc_url);
switch_pools(NULL);
} else