Browse Source

Return error if BFL take longer then 10s

Paul Sheppard 14 years ago
parent
commit
4db47aa57a
1 changed files with 7 additions and 1 deletions
  1. 7 1
      driver-bitforce.c

+ 7 - 1
driver-bitforce.c

@@ -329,7 +329,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 
 
 	usleep(4500000);
 	usleep(4500000);
 	i = 4500;
 	i = 4500;
-	while (1) {
+	while (i < 10000) {
 		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])) {
@@ -341,6 +341,12 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 		usleep(10000);
 		usleep(10000);
 		i += 10;
 		i += 10;
 	}
 	}
+
+    if (i >= 10000) {
+	  applog(LOG_DEBUG, "BitForce took longer than 10s");
+      return 0;
+    }
+
 	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;
 	if (pdevbuf[2] == '-')
 	if (pdevbuf[2] == '-')