[sheepdog] [PATCH] don't see errno when read/2 returns zero

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Wed May 1 07:37:29 CEST 2013


read/2 set errno only when it returns -1.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 lib/net.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/net.c b/lib/net.c
index f25e733..ebb0da6 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -275,7 +275,11 @@ int do_read(int sockfd, void *buf, int len, bool (*need_retry)(uint32_t epoch),
 	int ret, repeat = MAX_RETRY_COUNT;
 reread:
 	ret = read(sockfd, buf, len);
-	if (ret < 0 || !ret) {
+	if (ret == 0) {
+		sd_eprintf("connection is closed (%d bytes left)", len);
+		return 1;
+	}
+	if (ret < 0) {
 		if (errno == EINTR)
 			goto reread;
 		/*
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list