From 181cb1635f6fcb209931da805bc2b9665d4eb666 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 24 Apr 2013 21:26:44 +1000 Subject: [PATCH] There should be no error response code with return value 0 in recv_line. --- util.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/util.c b/util.c index b00417e7..94c62ecf 100644 --- a/util.c +++ b/util.c @@ -1104,19 +1104,17 @@ char *recv_line(struct pool *pool) memset(s, 0, RBUFSIZE); n = recv(pool->sock, s, RECVSIZE, 0); - if (n < 1) { - if (errno != EAGAIN && errno != EWOULDBLOCK) { - if (n == 0) - ret = RECV_CLOSED; - else - ret = RECV_RECVFAIL; - break; - } - } else { - slen = strlen(s); - recalloc_sock(pool, slen); - strcat(pool->sockbuf, s); + if (!n) { + ret = RECV_CLOSED; + break; + } + if (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { + ret = RECV_RECVFAIL; + break; } + slen = strlen(s); + recalloc_sock(pool, slen); + strcat(pool->sockbuf, s); cgtime(&now); } while (tdiff(&now, &rstart) < 60 && !strstr(pool->sockbuf, "\n")); mutex_unlock(&pool->stratum_lock);