Browse Source

Get the current pool priority under lock to avoid dereferencing.

Con Kolivas 14 years ago
parent
commit
e1c7235227
1 changed files with 11 additions and 1 deletions
  1. 11 1
      main.c

+ 11 - 1
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)
 static void pool_resus(struct pool *pool)
 {
 {
 	applog(LOG_WARNING, "Pool %d %s recovered", pool->pool_no, pool->rpc_url);
 	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);
 		switch_pools(NULL);
 }
 }