Browse Source

Added 30s BFL hashing timeout

Paul Sheppard 13 years ago
parent
commit
ed06c97e2e
1 changed files with 10 additions and 1 deletions
  1. 10 1
      driver-bitforce.c

+ 10 - 1
driver-bitforce.c

@@ -39,6 +39,7 @@
 
 
 #define BITFORCE_SLEEP_US 4500000
 #define BITFORCE_SLEEP_US 4500000
 #define BITFORCE_SLEEP_MS (BITFORCE_SLEEP_US/1000)
 #define BITFORCE_SLEEP_MS (BITFORCE_SLEEP_US/1000)
+#define BITFORCE_TIMEOUT_MS 30000
 
 
 struct device_api bitforce_api;
 struct device_api bitforce_api;
 
 
@@ -346,7 +347,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 	int i;
 	int i;
 
 
 	i = BITFORCE_SLEEP_MS;
 	i = BITFORCE_SLEEP_MS;
-	while (1) {
+	while (i < BITFORCE_TIMEOUT_MS) {
 		BFwrite(fdDev, "ZFX", 3);
 		BFwrite(fdDev, "ZFX", 3);
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 		if (unlikely(!pdevbuf[0])) {
 		if (unlikely(!pdevbuf[0])) {
@@ -358,6 +359,14 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 		usleep(10000);
 		usleep(10000);
 		i += 10;
 		i += 10;
 	}
 	}
+	
+	if (i >= BITFORCE_TIMEOUT_MS) {
+		applog(LOG_ERR, "BitForce took longer than 30s");
+		bitforce->device_last_not_well = time(NULL);
+		bitforce->device_not_well_reason = REASON_THREAD_ZERO_HASH;
+		bitforce->thread_zero_hash_count++;
+		return 1;
+	}
 
 
 	applog(LOG_DEBUG, "BitForce waited %dms until %s\n", i, pdevbuf);
 	applog(LOG_DEBUG, "BitForce waited %dms until %s\n", i, pdevbuf);
 	work->blk.nonce = 0xffffffff;
 	work->blk.nonce = 0xffffffff;