Check for a restart before a timeout in message parsing code in avalon.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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;
}
}
}