Fix poll and select POSIX compliancy details about errors
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 25 Mar 2020 12:56:56 +0000 (12:56 +0000)
committerAurelien Jarno <aurel32@debian.org>
Wed, 25 Mar 2020 12:56:56 +0000 (12:56 +0000)
commit095d5a9c521ae64d5fe91122031462bd33472744
treee4818e82cab321118082a9d5806bd70a6647ad5f
parent049e81be06844766e898d21f635af04b0750bc65
Fix poll and select POSIX compliancy details about errors

This fixes the following:

This fixes the following:

- On error, poll must not return without polling, including EBADF, and instead
report POLLHUP/POLLERR/POLLNVAL
- Select must report EBADF if some set contains an invalid FD.

The idea is to move error management to after all select calls, in the
poll/select final treatment. The error is instead recorded in a new `error'
field, and a new SELECT_ERROR bit set.

Thanks Svante Signell for the initial version of the patch.

* hurd/hurdselect.c (SELECT_ERROR): New macro.
(_hurd_select):
- Add `error' field to `d' structures array.
- If a poll descriptor is bogus, set EBADF, but continue with a zero timeout.
- Go through the whole fd_set, not only until _hurd_dtablesize. Return EBADF
there is any bit set above _hurd_dtablesize.
- Do not request io_select on bogus descriptors (SELECT_ERROR).
- On io_select request error, record the error.
- On io_select bogus reply, use EIO error code.
- On io_select bogus or error reply, record the error.
- Do not destroy reply port for bogus FDs.
- On error, make poll set POLLHUP in the EPIPE case, POLLNVAL in the EBADF
case, or else POLLERR.
- On error, make select simulated readiness.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-poll_errors_fixes.diff
hurd/hurdselect.c