Commit 53a047d0070933354efbd839026896cd83c1caa5

Con Kolivas 2013-04-07T14:53:36

Check for a restart before a timeout in message parsing code in avalon.

diff --git a/driver-avalon.c b/driver-avalon.c
index 5a23cbf..98c7fc9 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -234,23 +234,23 @@ static int avalon_gets(int fd, uint8_t *buf, int read_count,
 			continue;
 		}
 
-		rc++;
-		if (rc >= read_count) {
+		if (thr && thr->work_restart) {
 			if (opt_debug) {
 				applog(LOG_WARNING,
-				       "Avalon: No data in %.2f seconds",
-				       (float)rc/(float)AVALON_TIME_FACTOR);
+				       "Avalon: Work restart at %.2f seconds",
+				       (float)(rc)/(float)AVALON_TIME_FACTOR);
 			}
-			return AVA_GETS_TIMEOUT;
+			return AVA_GETS_RESTART;
 		}
 
-		if (thr && thr->work_restart) {
+		rc++;
+		if (rc >= read_count) {
 			if (opt_debug) {
 				applog(LOG_WARNING,
-				       "Avalon: Work restart at %.2f seconds",
-				       (float)(rc)/(float)AVALON_TIME_FACTOR);
+				       "Avalon: No data in %.2f seconds",
+				       (float)rc/(float)AVALON_TIME_FACTOR);
 			}
-			return AVA_GETS_RESTART;
+			return AVA_GETS_TIMEOUT;
 		}
 	}
 }