On Tue, Apr 6, 2010 at 2:03 PM, Alexandre Julliard <julli...@winehq.org> wrote: > Mike Kaplinskiy <mike.kaplins...@gmail.com> writes: > >> Would allowing adding the fd to the poll loop after it has been >> removed be more sane? Otherwise we have to resort to ugly things like >> sock_try_event (which only half work). > > I don't think that makes sense either. The error condition is not going > to go away so you can no longer poll on it anyway, you really need to > close the socket and create a new one. > > -- > Alexandre Julliard > julli...@winehq.org >
That's only true in the case of a full close; if you do shutdown(,SD_SEND) on the remote end, we will get POLLIN/0 recv, but if we decide to do a send after that and the connection gets broken (either the remote fully closes the socket or we get connection reset), we will receive a POLLHUP/POLLERR with a different error code, which is what windows reports. The problem is that there are two halves of the connection to hang up (when both have hangup we get a POLLHUP, otherwise just a POLLIN/0 recv). (data from http://www.greenend.org.uk/rjk/2001/06/poll.html ) But I see your point that perhaps it doesn't belong in the main loop when one of the halves gets closed. I guess we can keep sock_try_event around but only use it when the socket has been removed from the main loop. I'll also add detection of half-closed connection and drop that event if the other half hasn't hung up yet. Sadly looks like MacOS will be left out of that detection since it reports POLLIN|POLLHUP for everything. Does that sound good? Mike.