[Sheepdog] [PATCH] fix a bug in rx() when read() returns 0 but connection is not marked as closed.
Yunkai Zhang
yunkai.me at gmail.com
Wed Apr 25 07:20:28 CEST 2012
On Wed, Apr 25, 2012 at 1:07 PM, MORITA Kazutaka
<morita.kazutaka at gmail.com> wrote:
> On Wed, Apr 25, 2012 at 10:05 AM, Huxinwei <huxinwei at huawei.com> wrote:
>>> -----Original Message-----
>>> From: MORITA Kazutaka [mailto:morita.kazutaka at gmail.com]
>>> Sent: Tuesday, April 24, 2012 5:21 PM
>>> To: Huxinwei
>>> Cc: Li Wenpeng; sheepdog at lists.wpkg.org
>>> Subject: Re: [Sheepdog] [PATCH] fix a bug in rx() when read() returns 0 but
>>> connection is not marked as closed.
>>>
>>> On Tue, Apr 24, 2012 at 5:40 PM, Huxinwei <huxinwei at huawei.com> wrote:
>>> > I proposed something similar a while ago.
>>> > The connection is actually staying in CLOSE_WAIT status while this happens.
>>> I'd suggest you consider something more reliable.
>>>
>>> Is there any case that read() returns zero but the connection is not closed?
>>
>> What if reading is interrupted by a signal ?
>> Read() returns 0 while errno is EINTR then ?
>
> No, it returns -1 when errno is set.
Agree.
read() reurns 0 just means END OF FILE.
In other words, the connection is alive in this case.
Sheep should not check errno while read() returns 0.
>
> http://www.kernel.org/doc/man-pages/online/pages/man2/read.2.html
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog
--
Yunkai Zhang
Work at Taobao
More information about the sheepdog
mailing list