Date: Sat, 03 Sep 2011 00:09:19 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: freebsd-net@FreeBSD.org, freebsd-standards@FreeBSD.org, Jilles Tjoelker <jilles@stack.nl> Subject: Re: POLLHUP on never connected socket Message-ID: <4E6145FF.3090803@FreeBSD.org> In-Reply-To: <20110903053813.V2093@besplex.bde.org> References: <4E60A1B8.7080607@FreeBSD.org> <20110902104018.GA12845@stack.nl> <20110903015445.J957@besplex.bde.org> <4E6123F4.4010209@FreeBSD.org> <20110903053813.V2093@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
on 02/09/2011 23:26 Bruce Evans said the following:
> Yes, that's what I'm asking. It should be simpler to fix if it is just
> a bug and doesn't involve reader/writer races. The code for setting
> POLLHUP for sockets is simple: from uipc_socket.c:
>
> % if ((events & POLLINIGNEOF) == 0) {
> % if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
> % revents |= events & (POLLIN | POLLRDNORM);
> % if (so->so_snd.sb_state & SBS_CANTSENDMORE)
> % revents |= POLLHUP;
> % }
> % }
>
> So POLLHUP tracks SBS_CANTRCVMORE && SBS_CANTSENDMORE exactly, and POLLHUP
> is never set without POLLIN.
Umm, it seems that when you say that then you are assuming that the events
contain POLLIN.
In what I observe events == POLLOUT | POLLPRI and thus only POLLHUP is set in
the revents.
Not that this means too much, just an observation.
> But in my version:
>
> % if ((events & POLLINIGNEOF) == 0) {
> % if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
> % if (so->so_snd.sb_state & SBS_CANTSENDMORE)
> % revents |= POLLHUP;
> % else
> % revents |= events & (POLLIN | POLLRDNORM);
> % }
> % }
>
> POLLIN is not set by hangup, bit actually means that there is (non-null)
> input available. jilles referred to this bug in -current.
--
Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E6145FF.3090803>
