Added 30s BFL hashing timeout
diff --git a/driver-bitforce.c b/driver-bitforce.c
index 5d4c0bb..e2d6430 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -39,6 +39,7 @@
#define BITFORCE_SLEEP_US 4500000
#define BITFORCE_SLEEP_MS (BITFORCE_SLEEP_US/1000)
+#define BITFORCE_TIMEOUT_MS 30000
struct device_api bitforce_api;
@@ -346,7 +347,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
int i;
i = BITFORCE_SLEEP_MS;
- while (1) {
+ while (i < BITFORCE_TIMEOUT_MS) {
BFwrite(fdDev, "ZFX", 3);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
if (unlikely(!pdevbuf[0])) {
@@ -358,6 +359,14 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
usleep(10000);
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);
work->blk.nonce = 0xffffffff;