This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/13660] poll wrong revents returned


http://sourceware.org/bugzilla/show_bug.cgi?id=13660

--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2012-02-10 01:28:14 UTC ---
The current Linux behavior is completely conformant. Per POSIX:

If fildes refers to a socket, read() shall be equivalent to recv() with no
flags set.
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html)

Upon successful completion, recv() shall return the length of the message in
bytes. If no messages are available to be received and the peer has performed
an orderly shutdown, recv() shall return 0.
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html)

DESCRIPTION
...
POLLIN
Data other than high-priority data may be read without blocking.
[OB XSR]For STREAMS, this flag is set in revents even if the message is of zero
length. This flag shall be equivalent to POLLRDNORM | POLLRDBAND.
...
POLLHUP
A device has been disconnected, or a pipe or FIFO has been closed by the last
process that had it open for writing. Once set, the hangup state of a FIFO
shall persist until some process opens the FIFO for writing or until all
read-only file descriptors for the FIFO are closed. This event and POLLOUT are
mutually-exclusive; a stream can never be writable if a hangup has occurred.
However, this event and POLLIN, POLLRDNORM, POLLRDBAND, or POLLPRI are not
mutually-exclusive. This flag is only valid in the revents bitmask; it shall be
ignored in the events member.
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html)

[end citations]

Note that if sockets are implemented as STREAMS (the traditional sysv way),
POSIX *REQUIRES* poll to set the POLLIN flag when the socket is at EOF (see
above). If not, it makes no explicit requirement, but the fact that data
(zero-length) can be read without blocking implies that POLLIN should be set.
Moreover, the subsequent text for POLLHUP makes it clear that POLLIN and
POLLHUP are not mutually exclusive; both can (and probably should) be set when
the socket is at EOF, although POSIX does not seem to place any requirements
about POLLHUP for sockets. The entire text is in regards to "devices", pipes,
and FIFOs.

Please do not waste the kernel developers' time with your invalid bug report.
Plenty of applications depend on the correct behavior and nobody is going to
change it to meet your incorrect expectations. Just fix your application so
that it accepts both POLLIN and POLLHUP and you'll be able to support both
correct (Linux) and buggy (Windows?) implementations.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]