Browse Source

Bugfix: icarus: Check work restart before timeout

epoll always times out after its first return, which was a problem if it returned due to work restart
Luke Dashjr 12 years ago
parent
commit
408874e189
1 changed files with 8 additions and 8 deletions
  1. 8 8
      driver-icarus.c

+ 8 - 8
driver-icarus.c

@@ -253,26 +253,26 @@ int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct th
 			continue;
 		}
 			
-		rc++;
-		if (rc >= read_count) {
+		if (thr && thr->work_restart) {
 			if (epollfd != -1)
 				close(epollfd);
 			if (opt_debug) {
 				applog(LOG_DEBUG,
-					"Icarus Read: No data in %.2f seconds",
-					(float)rc * epoll_timeout / 1000.);
+					"Icarus Read: Interrupted by work restart");
 			}
-			return ICA_GETS_TIMEOUT;
+			return ICA_GETS_RESTART;
 		}
 
-		if (thr && thr->work_restart) {
+		rc++;
+		if (rc >= read_count) {
 			if (epollfd != -1)
 				close(epollfd);
 			if (opt_debug) {
 				applog(LOG_DEBUG,
-					"Icarus Read: Interrupted by work restart");
+					"Icarus Read: No data in %.2f seconds",
+					(float)rc * epoll_timeout / 1000.);
 			}
-			return ICA_GETS_RESTART;
+			return ICA_GETS_TIMEOUT;
 		}
 	}
 }