Get the current pool priority under lock to avoid dereferencing.
diff --git a/main.c b/main.c
index fdb4e3d..c6abeaf 100644
--- a/main.c
+++ b/main.c
@@ -3508,10 +3508,20 @@ static void pool_died(struct pool *pool)
}
}
+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)
{
applog(LOG_WARNING, "Pool %d %s recovered", pool->pool_no, pool->rpc_url);
- if (pool->prio < current_pool()->prio && pool_strategy == POOL_FAILOVER)
+ if (pool->prio < cp_prio() && pool_strategy == POOL_FAILOVER)
switch_pools(NULL);
}