From a9c4c1690d2caa11cbe1fe7e17c145ac7ebefd86 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 10 Jun 2014 16:30:40 +1000 Subject: [PATCH] Allow select to modify the timeout instead of it being reset on each pass through the read loop --- src/ckpool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index f1c7fbd5..8a7fbd6f 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -129,8 +129,8 @@ bool ping_main(ckpool_t *ckp) * of the buffer for use on the next receive. */ int read_socket_line(connsock_t *cs, int timeout) { + tv_t tv_timeout = {timeout, 0}; char *eom = NULL; - tv_t tv_timeout; size_t buflen; int ret = -1; fd_set rd; @@ -153,8 +153,8 @@ int read_socket_line(connsock_t *cs, int timeout) FD_ZERO(&rd); FD_SET(cs->fd, &rd); - tv_timeout.tv_sec = eom ? 0 : timeout; - tv_timeout.tv_usec = 0; + if (eom) + tv_timeout.tv_sec = tv_timeout.tv_usec = 0; ret = select(cs->fd + 1, &rd, NULL, NULL, &tv_timeout); if (eom && !ret) break;