Mercurial > code
changeset 283:d2d5a14bae10
Socket: check for POLLHUP if the socket has disconnect. Some implementations
mark the socket POLLIN whilst some other mark it POLLHUP.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 02 Nov 2014 17:57:55 +0100 |
parents | ea55a3886da0 |
children | 9be2cd100167 |
files | C++/SocketListener.cpp |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/C++/SocketListener.cpp Mon Oct 27 11:20:49 2014 +0100 +++ b/C++/SocketListener.cpp Sun Nov 02 17:57:55 2014 +0100 @@ -174,7 +174,14 @@ { int direction{}; - if (event & POLLIN) + /* + * Poll implementations mark the socket differently regarding + * the disconnection of a socket. + * + * At least, even if POLLHUP or POLLIN is set, recv() always + * return 0 so we mark the socket as readable. + */ + if ((event & POLLIN) || (event & POLLHUP)) direction |= Read; if (event & POLLOUT) direction |= Write;