[PATCH] chg: just take it as EOF if recv() returns 0

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Aug 6 09:37:27 EDT 2016



On 08/06/2016 11:42 AM, Jun Wu wrote:
> Yes, please.

Pushed, thanks

>
> Excerpts from Yuya Nishihara's message of 2016-08-06 13:51:39 +0900:
>> # HG changeset patch
>> # User Yuya Nishihara <yuya at tcha.org>
>> # Date 1470399693 -32400
>> #      Fri Aug 05 21:21:33 2016 +0900
>> # Node ID e59b4315a3f8602582f0d39e1c531faaa3119982
>> # Parent  56e9357be6b2704678331999e8b4b02777fc724b
>> 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.
>>
>> diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
>> --- a/contrib/chg/hgclient.c
>> +++ b/contrib/chg/hgclient.c
>> @@ -126,15 +126,10 @@ static void readchannel(hgclient_t *hgc)
>>          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;
>>      }
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list