From 53a047d0070933354efbd839026896cd83c1caa5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 7 Apr 2013 14:53:36 +1000 Subject: [PATCH] Check for a restart before a timeout in message parsing code in avalon. --- driver-avalon.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/driver-avalon.c b/driver-avalon.c index 5a23cbf7..98c7fc9a 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; } } }