From c6ca12f08477ee094b123012f3db8d51bd50cc2a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 6 Apr 2013 11:21:55 +1100 Subject: [PATCH] Differentiate socket closed from socket error in recv_line. --- util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 4428199f..5665f809 100644 --- a/util.c +++ b/util.c @@ -1038,11 +1038,16 @@ char *recv_line(struct pool *pool) mutex_lock(&pool->stratum_lock); do { char s[RBUFSIZE]; - size_t slen, n; + size_t slen; + ssize_t n; memset(s, 0, RBUFSIZE); n = recv(pool->sock, s, RECVSIZE, 0); - if (n < 1 && errno != EAGAIN && errno != EWOULDBLOCK) { + if (!n) { + applog(LOG_DEBUG, "Socket closed waiting in recv_line"); + break; + } + if (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { applog(LOG_DEBUG, "Failed to recv sock in recv_line"); break; }