Browse Source

Merge branch 'failsafe_soa' into bfgminer-2.6.x

Luke Dashjr 13 years ago
parent
commit
6d887fc01c
3 changed files with 24 additions and 12 deletions
  1. 4 0
      api.c
  2. 19 12
      miner.c
  3. 1 0
      miner.h

+ 4 - 0
api.c

@@ -175,6 +175,7 @@ static const char *WAIT = "Waiting";
 static const char *DISABLED = "Disabled";
 static const char *DISABLED = "Disabled";
 static const char *ALIVE = "Alive";
 static const char *ALIVE = "Alive";
 static const char *REJECTING = "Rejecting";
 static const char *REJECTING = "Rejecting";
+static const char *STALE = "Stale";
 static const char *UNKNOWN = "Unknown";
 static const char *UNKNOWN = "Unknown";
 #define _DYNAMIC "D"
 #define _DYNAMIC "D"
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
@@ -1674,6 +1675,9 @@ static void poolstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
 			case POOL_REJECTING:
 			case POOL_REJECTING:
 				status = (char *)REJECTING;
 				status = (char *)REJECTING;
 				break;
 				break;
+			case POOL_STALE:
+				status = (char *)STALE;
+				break;
 			case POOL_ENABLED:
 			case POOL_ENABLED:
 				if (pool->idle)
 				if (pool->idle)
 					status = (char *)DEAD;
 					status = (char *)DEAD;

+ 19 - 12
miner.c

@@ -1917,19 +1917,15 @@ static void enable_pool(struct pool *pool)
 	}
 	}
 }
 }
 
 
-static void disable_pool(struct pool *pool)
+static void disable_pool2(struct pool *pool, enum pool_enable pe)
 {
 {
 	if (pool->enabled == POOL_ENABLED)
 	if (pool->enabled == POOL_ENABLED)
 		enabled_pools--;
 		enabled_pools--;
-	pool->enabled = POOL_DISABLED;
+	pool->enabled = pe;
 }
 }
 
 
-static void reject_pool(struct pool *pool)
-{
-	if (pool->enabled == POOL_ENABLED)
-		enabled_pools--;
-	pool->enabled = POOL_REJECTING;
-}
+#define disable_pool(pool)  disable_pool2(pool, POOL_DISABLED)
+#define  reject_pool(pool)  disable_pool2(pool, POOL_REJECTING)
 
 
 static bool submit_upstream_work(const struct work *work, CURL *curl)
 static bool submit_upstream_work(const struct work *work, CURL *curl)
 {
 {
@@ -3190,20 +3186,26 @@ static void *stage_thread(void *userdata)
 
 
 		test_work_current(work);
 		test_work_current(work);
 
 
+		struct pool *pool = work->pool;
 		if (stale_work3(work, false, false)) {
 		if (stale_work3(work, false, false)) {
 			struct timeval now;
 			struct timeval now;
 			gettimeofday(&now, NULL);
 			gettimeofday(&now, NULL);
-			if (work->tv_staged.tv_sec >= now.tv_sec - 2) {
+			if (work->tv_staged.tv_sec >= now.tv_sec - 2 && pool->enabled != POOL_REJECTING) {
 				// Only for freshly fetched work, disable the pool giving it to us stale
 				// Only for freshly fetched work, disable the pool giving it to us stale
-				struct pool *pool = work->pool;
 				applog(LOG_WARNING, "Pool %u gave us stale-on-arrival work, disabling!", pool->pool_no);
 				applog(LOG_WARNING, "Pool %u gave us stale-on-arrival work, disabling!", pool->pool_no);
-				reject_pool(pool);
+				disable_pool2(pool, POOL_STALE);
 				if (pool == current_pool())
 				if (pool == current_pool())
 					switch_pools(NULL);
 					switch_pools(NULL);
 			}
 			}
 			continue;
 			continue;
 		}
 		}
 
 
+		if (unlikely(pool->enabled == POOL_STALE)) {
+			applog(LOG_WARNING, "Stale pool %d no longer giving stale work, re-enabling!", pool->pool_no);
+			enable_pool(pool);
+			switch_pools(NULL);
+		}
+
 		applog(LOG_DEBUG, "Pushing work to getwork queue");
 		applog(LOG_DEBUG, "Pushing work to getwork queue");
 
 
 		if (unlikely(!hash_push(work))) {
 		if (unlikely(!hash_push(work))) {
@@ -3548,6 +3550,9 @@ updated:
 			case POOL_REJECTING:
 			case POOL_REJECTING:
 				wlogprint("Rejecting ");
 				wlogprint("Rejecting ");
 				break;
 				break;
+			case POOL_STALE:
+				wlogprint("Stale ");
+				break;
 		}
 		}
 		wlogprint("%s Priority %d: %s  User:%s\n",
 		wlogprint("%s Priority %d: %s  User:%s\n",
 			pool->idle? "Dead" : "Alive",
 			pool->idle? "Dead" : "Alive",
@@ -4903,7 +4908,9 @@ static struct pool *select_longpoll_pool(struct pool *cp)
  */
  */
 static void wait_lpcurrent(struct pool *pool)
 static void wait_lpcurrent(struct pool *pool)
 {
 {
-	if (pool->enabled == POOL_REJECTING || pool_strategy == POOL_LOADBALANCE)
+	if (pool->enabled == POOL_REJECTING || pool_strategy == POOL_LOADBALANCE
+	 || pool->enabled == POOL_STALE
+	)
 		return;
 		return;
 
 
 	while (pool != current_pool() && pool_strategy != POOL_LOADBALANCE) {
 	while (pool != current_pool() && pool_strategy != POOL_LOADBALANCE) {

+ 1 - 0
miner.h

@@ -770,6 +770,7 @@ enum pool_enable {
 	POOL_DISABLED,
 	POOL_DISABLED,
 	POOL_ENABLED,
 	POOL_ENABLED,
 	POOL_REJECTING,
 	POOL_REJECTING,
+	POOL_STALE,
 };
 };
 
 
 struct pool {
 struct pool {