Browse Source

Bugfix: icarus: Avoid trying to submit 0 on comms error

Luke Dashjr 12 years ago
parent
commit
5221d502e8
1 changed files with 9 additions and 4 deletions
  1. 9 4
      driver-icarus.c

+ 9 - 4
driver-icarus.c

@@ -944,8 +944,13 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 		timersub(&state->tv_workfinish, &tv_start, &elapsed);
 	}
 	else
-	if (fd == -1 && !icarus_reopen(icarus, state, &fd))
-		return -1;
+	{
+		if (fd == -1 && !icarus_reopen(icarus, state, &fd))
+			return -1;
+		
+		// First run; no nonce, no hashes done
+		ret = ICA_GETS_ERROR;
+	}
 
 #ifndef WIN32
 	tcflush(fd, TCOFLUSH);
@@ -955,7 +960,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 
 	// Handle dynamic clocking for "subclass" devices
 	// This needs to run before sending next job, since it hashes the command too
-	if (info->dclk.freqM && likely(!was_first_run)) {
+	if (info->dclk.freqM && likely(ret == ICA_GETS_OK || ret == ICA_GETS_TIMEOUT)) {
 		int qsec = ((4 * elapsed.tv_sec) + (elapsed.tv_usec / 250000)) ?: 1;
 		for (int n = qsec; n; --n)
 			dclk_gotNonces(&info->dclk);
@@ -977,7 +982,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 
 	work->blk.nonce = 0xffffffff;
 
-	if (was_first_run) {
+	if (ret == ICA_GETS_ERROR) {
 		state->firstrun = false;
 		icarus_transition_work(state, work);
 		hash_count = 0;