Browse Source

Always check if we should switch pools when enabling one, and always enable pools we want to switch to

Luke Dashjr 11 years ago
parent
commit
8522463f19
2 changed files with 7 additions and 9 deletions
  1. 0 3
      api.c
  2. 7 6
      miner.c

+ 0 - 3
api.c

@@ -2329,7 +2329,6 @@ static void switchpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 
 	pool = pools[id];
 	pool->failover_only = false;
-	enable_pool(pool);
 	cg_runlock(&control_lock);
 	switch_pools(pool);
 
@@ -2449,8 +2448,6 @@ static void enablepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 
 	pool->failover_only = false;
 	enable_pool(pool);
-	if (pool->prio < current_pool()->prio)
-		switch_pools(pool);
 
 	message(io_data, MSG_ENAPOOL, id, NULL, isjson);
 }

+ 7 - 6
miner.c

@@ -1083,10 +1083,10 @@ struct pool *add_pool(void)
 	
 	adjust_quota_gcd();
 	
-	enable_pool(pool);
-	
 	if (!currentpool)
 		currentpool = pool;
+	
+	enable_pool(pool);
 
 	return pool;
 }
@@ -4403,6 +4403,8 @@ void enable_pool(struct pool * const pool)
 		pool->enabled = POOL_ENABLED;
 		pthread_cond_broadcast(&lp_cond);
 		mutex_unlock(&lp_lock);
+		if (pool->prio < current_pool()->prio)
+			switch_pools(pool);
 	}
 }
 
@@ -4536,7 +4538,6 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
 		if (unlikely(pool->enabled == POOL_REJECTING)) {
 			applog(LOG_WARNING, "Rejecting pool %d now accepting shares, re-enabling!", pool->pool_no);
 			enable_pool(pool);
-			switch_pools(NULL);
 		}
 
 		if (unlikely(work->block)) {
@@ -6357,6 +6358,9 @@ void switch_pools(struct pool *selected)
 	struct pool *pool, *last_pool, *failover_pool = NULL;
 	int i, pool_no, next_pool;
 
+	if (selected)
+		enable_pool(selected);
+	
 	cg_wlock(&control_lock);
 	last_pool = currentpool;
 	pool_no = currentpool->pool_no;
@@ -7311,7 +7315,6 @@ retry:
 		}
 		pool = pools[selected];
 		pool->failover_only = false;
-		enable_pool(pool);
 		switch_pools(pool);
 		goto updated;
 	} else if (!strncasecmp(&input, "d", 1)) {
@@ -7336,8 +7339,6 @@ retry:
 		pool = pools[selected];
 		pool->failover_only = false;
 		enable_pool(pool);
-		if (pool->prio < current_pool()->prio)
-			switch_pools(pool);
 		goto updated;
 	} else if (!strncasecmp(&input, "c", 1)) {
 		for (i = 0; i <= TOP_STRATEGY; i++)