Browse Source

Combine reject_pool into disable_pool function, and don't allow it to override a manual disable

Signed-off-by: Huang Le <4tarhl@gmail.com>
Huang Le 11 years ago
parent
commit
6518f1fc34
3 changed files with 19 additions and 18 deletions
  1. 1 1
      api.c
  2. 17 16
      miner.c
  3. 1 1
      miner.h

+ 1 - 1
api.c

@@ -2553,7 +2553,7 @@ static void disablepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, ch
 		return;
 		return;
 	}
 	}
 
 
-	disable_pool(pool);
+	disable_pool(pool, POOL_DISABLED);
 
 
 	message(io_data, MSG_DISPOOL, id, NULL, isjson);
 	message(io_data, MSG_DISPOOL, id, NULL, isjson);
 }
 }

+ 17 - 16
miner.c

@@ -4406,20 +4406,21 @@ void enable_pool(struct pool * const pool)
 	}
 	}
 }
 }
 
 
-void disable_pool(struct pool * const pool)
+void disable_pool(struct pool * const pool, const enum pool_enable enable_status)
 {
 {
-	if (pool->enabled == POOL_ENABLED)
-		enabled_pools--;
-	pool->enabled = POOL_DISABLED;
-	if (pool == current_pool())
-		switch_pools(NULL);
-}
-
-static void reject_pool(struct pool *pool)
-{
-	if (pool->enabled == POOL_ENABLED)
-		enabled_pools--;
-	pool->enabled = POOL_REJECTING;
+	if (pool->enabled == POOL_DISABLED)
+		/* had been manually disabled before */
+		return;
+	
+	if (pool->enabled != POOL_ENABLED)
+	{
+		/* has been programmatically disabled already, just change to the new status directly */
+		pool->enabled = enable_status;
+		return;
+	}
+	
+	--enabled_pools;
+	pool->enabled = enable_status;
 	if (pool == current_pool())
 	if (pool == current_pool())
 		switch_pools(NULL);
 		switch_pools(NULL);
 }
 }
@@ -4611,7 +4612,7 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
 			if (pool->seq_rejects > utility * 3) {
 			if (pool->seq_rejects > utility * 3) {
 				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);
+				disable_pool(pool, POOL_REJECTING);
 				pool->seq_rejects = 0;
 				pool->seq_rejects = 0;
 			}
 			}
 		}
 		}
@@ -6864,7 +6865,7 @@ void remove_pool(struct pool *pool)
 	int i, last_pool = total_pools - 1;
 	int i, last_pool = total_pools - 1;
 	struct pool *other;
 	struct pool *other;
 
 
-	disable_pool(pool);
+	disable_pool(pool, POOL_DISABLED);
 	
 	
 	/* Boost priority of any lower prio than this one */
 	/* Boost priority of any lower prio than this one */
 	for (i = 0; i < total_pools; i++) {
 	for (i = 0; i < total_pools; i++) {
@@ -7320,7 +7321,7 @@ retry:
 			goto retry;
 			goto retry;
 		}
 		}
 		pool = pools[selected];
 		pool = pools[selected];
-		disable_pool(pool);
+		disable_pool(pool, POOL_DISABLED);
 		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");

+ 1 - 1
miner.h

@@ -1493,7 +1493,7 @@ 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 enable_pool(struct pool *);
-extern void disable_pool(struct pool *);
+extern void disable_pool(struct pool *, enum pool_enable);
 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);