Browse Source

Merge pull request #188 from luke-jr/failsafe

Help keep cgminer alive when devices fail
Con Kolivas 14 years ago
parent
commit
306629f859
2 changed files with 14 additions and 6 deletions
  1. 5 1
      cgminer.c
  2. 9 5
      driver-bitforce.c

+ 5 - 1
cgminer.c

@@ -3831,11 +3831,14 @@ void *miner_thread(void *userdata)
 			}
 			}
 
 
 			if (unlikely(!hashes)) {
 			if (unlikely(!hashes)) {
+				applog(LOG_ERR, "%s %d failure, disabling!", api->name, cgpu->device_id);
+				cgpu->deven = DEV_DISABLED;
+
 				cgpu->device_last_not_well = time(NULL);
 				cgpu->device_last_not_well = time(NULL);
 				cgpu->device_not_well_reason = REASON_THREAD_ZERO_HASH;
 				cgpu->device_not_well_reason = REASON_THREAD_ZERO_HASH;
 				cgpu->thread_zero_hash_count++;
 				cgpu->thread_zero_hash_count++;
 
 
-				goto out;
+				goto disabled;
 			}
 			}
 
 
 			hashes_done += hashes;
 			hashes_done += hashes;
@@ -3896,6 +3899,7 @@ void *miner_thread(void *userdata)
 
 
 			if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED)) {
 			if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED)) {
 				applog(LOG_WARNING, "Thread %d being disabled", thr_id);
 				applog(LOG_WARNING, "Thread %d being disabled", thr_id);
+disabled:
 				mythr->rolling = mythr->cgpu->rolling = 0;
 				mythr->rolling = mythr->cgpu->rolling = 0;
 				applog(LOG_DEBUG, "Popping wakeup ping in miner thread");
 				applog(LOG_DEBUG, "Popping wakeup ping in miner thread");
 				thread_reportout(mythr);
 				thread_reportout(mythr);

+ 9 - 5
driver-bitforce.c

@@ -79,14 +79,18 @@ static void BFgets(char *buf, size_t bufLen, int fd)
 	buf[0] = '\0';
 	buf[0] = '\0';
 }
 }
 
 
-static void BFwrite(int fd, const void *buf, ssize_t bufLen)
+static ssize_t BFwrite2(int fd, const void *buf, ssize_t bufLen)
 {
 {
-	ssize_t ret = write(fd, buf, bufLen);
-
-	if (unlikely(ret != bufLen))
-		quit(1, "BFwrite failed");
+	return write(fd, buf, bufLen);
 }
 }
 
 
+#define BFwrite(fd, buf, bufLen)  do {  \
+	if ((bufLen) != BFwrite2(fd, buf, bufLen)) {  \
+		applog(LOG_ERR, "Error writing to BitForce (" #buf ")");  \
+		return 0;  \
+	}  \
+} while(0)
+
 #define BFclose(fd) close(fd)
 #define BFclose(fd) close(fd)
 
 
 static bool bitforce_detect_one(const char *devpath)
 static bool bitforce_detect_one(const char *devpath)