Browse Source

Bugfix: Always call enable_pool and disable_pool to ensure consistent handling of the situations

Huang Le 11 years ago
parent
commit
d338c29938
4 changed files with 16 additions and 16 deletions
  1. 1 0
      AUTHORS
  2. 4 6
      api.c
  3. 9 10
      miner.c
  4. 2 0
      miner.h

+ 1 - 0
AUTHORS

@@ -43,6 +43,7 @@ gluk <glukolog@mail.ru>
 Graeme Humphries <graeme@sudo.ca>
 Graeme Humphries <graeme@sudo.ca>
 GridSeed Team <develop@gridseed.com>
 GridSeed Team <develop@gridseed.com>
 HashBuster team <contact@hashbuster.com>
 HashBuster team <contact@hashbuster.com>
+Huang Le <4tarhl@gmail.com>
 Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
 Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
 James Hilliard <james.hilliard1@gmail.com>
 James Hilliard <james.hilliard1@gmail.com>
 James Morris <jmorris@intercode.com.au>
 James Morris <jmorris@intercode.com.au>

+ 4 - 6
api.c

@@ -2329,7 +2329,7 @@ static void switchpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 
 
 	pool = pools[id];
 	pool = pools[id];
 	pool->failover_only = false;
 	pool->failover_only = false;
-	pool->enabled = POOL_ENABLED;
+	enable_pool(pool);
 	cg_runlock(&control_lock);
 	cg_runlock(&control_lock);
 	switch_pools(pool);
 	switch_pools(pool);
 
 
@@ -2448,7 +2448,7 @@ static void enablepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 	}
 	}
 
 
 	pool->failover_only = false;
 	pool->failover_only = false;
-	pool->enabled = POOL_ENABLED;
+	enable_pool(pool);
 	if (pool->prio < current_pool()->prio)
 	if (pool->prio < current_pool()->prio)
 		switch_pools(pool);
 		switch_pools(pool);
 
 
@@ -2553,9 +2553,7 @@ static void disablepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, ch
 		return;
 		return;
 	}
 	}
 
 
-	pool->enabled = POOL_DISABLED;
-	if (pool == current_pool())
-		switch_pools(NULL);
+	disable_pool(pool);
 
 
 	message(io_data, MSG_DISPOOL, id, NULL, isjson);
 	message(io_data, MSG_DISPOOL, id, NULL, isjson);
 }
 }
@@ -2597,7 +2595,7 @@ static void removepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 		return;
 		return;
 	}
 	}
 
 
-	pool->enabled = POOL_DISABLED;
+	disable_pool(pool);
 	rpc_url = escape_string(pool->rpc_url, isjson);
 	rpc_url = escape_string(pool->rpc_url, isjson);
 	if (rpc_url != pool->rpc_url)
 	if (rpc_url != pool->rpc_url)
 		dofree = true;
 		dofree = true;

+ 9 - 10
miner.c

@@ -1038,8 +1038,6 @@ void adjust_quota_gcd(void)
 	applog(LOG_DEBUG, "Global quota greatest common denominator set to %lu", gcd);
 	applog(LOG_DEBUG, "Global quota greatest common denominator set to %lu", gcd);
 }
 }
 
 
-static void enable_pool(struct pool *);
-
 /* Return value is ignored if not called from add_pool_details */
 /* Return value is ignored if not called from add_pool_details */
 struct pool *add_pool(void)
 struct pool *add_pool(void)
 {
 {
@@ -4397,7 +4395,7 @@ void logwin_update(void)
 }
 }
 #endif
 #endif
 
 
-static void enable_pool(struct pool *pool)
+void enable_pool(struct pool * const pool)
 {
 {
 	if (pool->enabled != POOL_ENABLED) {
 	if (pool->enabled != POOL_ENABLED) {
 		mutex_lock(&lp_lock);
 		mutex_lock(&lp_lock);
@@ -4408,20 +4406,22 @@ static void enable_pool(struct pool *pool)
 	}
 	}
 }
 }
 
 
-#ifdef HAVE_CURSES
-static void disable_pool(struct pool *pool)
+void disable_pool(struct pool * const pool)
 {
 {
 	if (pool->enabled == POOL_ENABLED)
 	if (pool->enabled == POOL_ENABLED)
 		enabled_pools--;
 		enabled_pools--;
 	pool->enabled = POOL_DISABLED;
 	pool->enabled = POOL_DISABLED;
+	if (pool == current_pool())
+		switch_pools(NULL);
 }
 }
-#endif
 
 
 static void reject_pool(struct pool *pool)
 static void reject_pool(struct pool *pool)
 {
 {
 	if (pool->enabled == POOL_ENABLED)
 	if (pool->enabled == POOL_ENABLED)
 		enabled_pools--;
 		enabled_pools--;
 	pool->enabled = POOL_REJECTING;
 	pool->enabled = POOL_REJECTING;
+	if (pool == current_pool())
+		switch_pools(NULL);
 }
 }
 
 
 static double share_diff(const struct work *);
 static double share_diff(const struct work *);
@@ -4612,8 +4612,6 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
 				applog(LOG_WARNING, "Pool %d rejected %d sequential shares, disabling!",
 				applog(LOG_WARNING, "Pool %d rejected %d sequential shares, disabling!",
 				       pool->pool_no, pool->seq_rejects);
 				       pool->pool_no, pool->seq_rejects);
 				reject_pool(pool);
 				reject_pool(pool);
-				if (pool == current_pool())
-					switch_pools(NULL);
 				pool->seq_rejects = 0;
 				pool->seq_rejects = 0;
 			}
 			}
 		}
 		}
@@ -7322,8 +7320,6 @@ retry:
 		}
 		}
 		pool = pools[selected];
 		pool = pools[selected];
 		disable_pool(pool);
 		disable_pool(pool);
-		if (pool == current_pool())
-			switch_pools(NULL);
 		goto updated;
 		goto updated;
 	} else if (!strncasecmp(&input, "e", 1)) {
 	} else if (!strncasecmp(&input, "e", 1)) {
 		selected = curses_int("Select pool number");
 		selected = curses_int("Select pool number");
@@ -12338,7 +12334,10 @@ int main(int argc, char *argv[])
 	
 	
 	if (opt_benchmark) {
 	if (opt_benchmark) {
 		while (total_pools)
 		while (total_pools)
+		{
+			disable_pool(pools[0]);
 			remove_pool(pools[0]);
 			remove_pool(pools[0]);
+		}
 
 
 		setup_benchmark_pool();
 		setup_benchmark_pool();
 	}
 	}

+ 2 - 0
miner.h

@@ -1492,6 +1492,8 @@ extern double cgpu_utility(struct cgpu_info *);
 extern void kill_work(void);
 extern void kill_work(void);
 extern int prioritize_pools(char *param, int *pid);
 extern int prioritize_pools(char *param, int *pid);
 extern void validate_pool_priorities(void);
 extern void validate_pool_priorities(void);
+extern void enable_pool(struct pool *);
+extern void disable_pool(struct pool *);
 extern void switch_pools(struct pool *selected);
 extern void switch_pools(struct pool *selected);
 extern void remove_pool(struct pool *pool);
 extern void remove_pool(struct pool *pool);
 extern void write_config(FILE *fcfg);
 extern void write_config(FILE *fcfg);