From 5e3474b0c8ef95c3b08ae587c138ea136fcc8362 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 8 Apr 2013 09:04:10 +1000 Subject: [PATCH] If we get a restart message in avalon_gets still check if there's a receive message to parse first without a timeout before returning AVA_GETS_RESTART. --- driver-avalon.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/driver-avalon.c b/driver-avalon.c index 3c8c7ebc..5b4d106b 100644 --- a/driver-avalon.c +++ b/driver-avalon.c @@ -209,9 +209,17 @@ static inline int avalon_gets(int fd, uint8_t *buf, struct thr_info *thr, ssize_t ret = 0; while (true) { - struct timeval timeout = {0, 100000}; + struct timeval timeout; fd_set rd; + timeout.tv_sec = 0; + /* If we get a restart message, still check if there's + * anything in the buffer waiting to be parsed */ + if (unlikely(thr->work_restart)) + timeout.tv_usec = 0; + else + timeout.tv_usec = 100000; + FD_ZERO(&rd); FD_SET(fd, &rd); ret = select(fd + 1, &rd, NULL, NULL, &timeout); @@ -232,7 +240,7 @@ static inline int avalon_gets(int fd, uint8_t *buf, struct thr_info *thr, continue; } - if (thr->work_restart) { + if (unlikely(thr->work_restart)) { applog(LOG_DEBUG, "Avalon: Work restart"); return AVA_GETS_RESTART; }