Mike Kaplinskiy mike.kaplinskiy@gmail.com writes:
This won't work for implementing half-closed sockets. If we have only the read half is closed, we will get POLLIN/0 recv indefinitely if we keep polling (not POLLHUP). If we remove it from the loop, we have to keep polling (once in a while, i.e. when an enable_socket_event gets through) until we get a POLLHUP/POLLERR which signals the other half is closed. On some platforms this won't work, but they will jump to a full close automatically (i.e. POLLHUP right away). The problem now is that if we receive a shutdown, we will spam FD_CLOSE on every successful send.
I don't see why. If you don't get POLLHUP then you can keep polling, just don't select for POLLIN once you have seen EOF. The problem with POLLHUP/POLLERR is that they can't be masked, but POLLIN doesn't have that issue.