changeset 29719:acf27be56d26

chg: just take it as EOF if recv() returns 0 hgc->sockfd is a blocking stream socket. recv() should never return 0 other than EOF. See 4fc4b8cc9957 for the original problem.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 05 Aug 2016 21:21:33 +0900
parents 2dd8c225e94c
children 041fecbb588a
files contrib/chg/hgclient.c
diffstat 1 files changed, 1 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/hgclient.c	Thu Aug 04 16:56:50 2016 +0200
+++ b/contrib/chg/hgclient.c	Fri Aug 05 21:21:33 2016 +0900
@@ -126,15 +126,10 @@
 		return;  /* assumes input request */
 
 	size_t cursize = 0;
-	int emptycount = 0;
 	while (cursize < hgc->ctx.datasize) {
 		rsize = recv(hgc->sockfd, hgc->ctx.data + cursize,
 			     hgc->ctx.datasize - cursize, 0);
-		/* rsize == 0 normally indicates EOF, while it's also a valid
-		 * packet size for unix socket. treat it as EOF and abort if
-		 * we get many empty responses in a row. */
-		emptycount = (rsize == 0 ? emptycount + 1 : 0);
-		if (rsize < 0 || emptycount > 20)
+		if (rsize < 1)
 			abortmsg("failed to read data block");
 		cursize += rsize;
 	}