From d76d187c5f75d963d1b70a5ddc2f368a7f4cfe04 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 30 Aug 2019 01:20:23 +0200 Subject: hurd: Fix poll and select POSIX compliancy details about errors 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. --- ChangeLog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index 37cbe28169..afd99a634e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,21 @@ (_hurd_canonicalize_directory_name_internal): Do not remove the heading slash if we got an unknown root directory. (__getcwd): Do not fail with EGRATUITOUS if we got an unknown root directory. + * 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. 2019-08-30 Richard Braun -- cgit v1.2.3