recv revert treating zero as hangup
authorAndy Green <andy@warmcat.com>
Thu, 5 May 2016 01:23:05 +0000 (09:23 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 5 May 2016 01:23:05 +0000 (09:23 +0800)
commitd2feeee1d6badd4f2da90d8bea29f58e77e0d68b
tree50320b4dd6a78b6e6e258b5f8aae0fbf04a7730c
parentf89e90f6a26800afad895a2a6fddf58fff4ae67b
recv revert treating zero as hangup

While checking with ab, I found
commit 30cdb3ac8f24a4c289a3b4e8a41d6c5f2e6ec959
Author: Justin Chen <justinchen00@github.invalid.com>
Date:   Thu Apr 14 21:40:53 2016 +0800

    recv treat zero return as error

    https://github.com/warmcat/libwebsockets/issues/475

turned ab performance to crap, reverting it made everything fast again.

recv manpage says there is three ways to get zero returned

1)       When a stream socket peer has performed an orderly shutdown, the return value will be 0  (the  traditional  "end-of-file"
       return).

2)       Datagram  sockets  in  various  domains  (e.g., the UNIX and Internet domains) permit zero-length datagrams.  When such a
       datagram is received, the return value is 0.

3)       The value 0 may also be returned if the requested number of bytes to receive from a stream socket was 0.

we can't just assume it means the peer shut down.

If the peer shut down, then the event loop should get an event on the socket like POLLHUP and deal with it that way.

So the patch mentioned above is simply reverted here.

Signed-off-by: Andy Green <andy@warmcat.com>
lib/output.c