From b44cbfebe30c47faace0a51bf33b7ea06cb4eda0 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Tue, 5 Jan 2016 16:15:11 -0700 Subject: [PATCH] Return 0 from OS_test_select_* ONLY if there are no pending... ...interrupts or subprocess status changes. --- src/microcode/uxio.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/microcode/uxio.c b/src/microcode/uxio.c index 6c3a01d6d..776523ca9 100644 --- a/src/microcode/uxio.c +++ b/src/microcode/uxio.c @@ -607,14 +607,16 @@ OS_test_select_registry (select_registry_t registry, int blockp) while (1) { int nfds = (safe_poll ((SR_ENTRIES (r)), (SR_N_FDS (r)), blockp)); - if (nfds >= 0) + if (nfds > 0) return (nfds); - if (errno != EINTR) + if (nfds < 0 && errno != EINTR) error_system_call (errno, syscall_select); if (OS_process_any_status_change ()) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } } @@ -629,14 +631,14 @@ OS_test_select_descriptor (int fd, int blockp, unsigned int mode) int nfds = (safe_poll (pfds, 1, blockp)); if (nfds > 0) return (ENCODE_MODE ((pfds [0]) . revents)); - if (nfds == 0) - return (0); - if (errno != EINTR) + if (nfds < 0 && errno != EINTR) error_system_call (errno, syscall_select); if (OS_process_any_status_change ()) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } } @@ -809,14 +811,16 @@ OS_test_select_registry (select_registry_t registry, int blockp) (SR_RREADERS (r)), (SR_RWRITERS (r)), blockp)); - if (nfds >= 0) + if (nfds > 0) return (nfds); - if (errno != EINTR) + if (nfds < 0 && errno != EINTR) error_system_call (errno, syscall_select); if (OS_process_any_status_change ()) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } #else error_system_call (ENOSYS, syscall_select); @@ -846,14 +850,14 @@ OS_test_select_descriptor (int fd, int blockp, unsigned int mode) return (((FD_ISSET (fd, (&readable))) ? SELECT_MODE_READ : 0) | ((FD_ISSET (fd, (&writeable))) ? SELECT_MODE_WRITE : 0)); - if (nfds == 0) - return (0); - if (errno != EINTR) + if (nfds < 0 && errno != EINTR) error_system_call (errno, syscall_select); if (OS_process_any_status_change ()) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } #else error_system_call (ENOSYS, syscall_select); -- 2.25.1