Browse Source

Merge pull request #253 from pshep/master

Clear buffer bug fix
Con Kolivas 13 years ago
parent
commit
892e9bf88a
1 changed files with 5 additions and 1 deletions
  1. 5 1
      driver-bitforce.c

+ 5 - 1
driver-bitforce.c

@@ -142,6 +142,10 @@ static void biforce_clear_buffer(struct cgpu_info *bitforce)
 {
 	int fdDev = bitforce->device_fd;
 	char pdevbuf[0x100];
+	int count = 0;
+
+	if (!fdDev)
+		return;
 
 	applog(LOG_DEBUG, "BFL%i: Clearing read buffer", bitforce->device_id);
 
@@ -149,7 +153,7 @@ static void biforce_clear_buffer(struct cgpu_info *bitforce)
 	do {
 		pdevbuf[0] = '\0';
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
-	} while (pdevbuf[0]);
+	} while (pdevbuf[0] && (++count < 10));
 	mutex_unlock(&bitforce->device_mutex);
 }