From 9d566d67fd3cfcc99752eea0519ad8451e584c71 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Fri, 19 Oct 2012 11:52:04 -0700 Subject: [PATCH] Fix test-select-descriptor, test-select-registry. Both test-select- primitives (in uxio.c) now return 0 only if there are no INTERRUPTs nor PROCESS-STATUS-CHANGEs pending. A previous attempt at this was incomplete or wrong (e.g. not spinning on interrupted calls when interrupts are masked). --- src/microcode/uxio.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/microcode/uxio.c b/src/microcode/uxio.c index 35c8db642..625820af7 100644 --- a/src/microcode/uxio.c +++ b/src/microcode/uxio.c @@ -607,7 +607,7 @@ 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 (nfds < 0 && errno != EINTR) error_system_call (errno, syscall_select); @@ -615,6 +615,8 @@ OS_test_select_registry (select_registry_t registry, int blockp) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } } @@ -635,8 +637,8 @@ OS_test_select_descriptor (int fd, int blockp, unsigned int mode) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); - /* nfds == 0, AND no status-change nor interrupts pending */ - return (0); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } } @@ -809,7 +811,7 @@ 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 (nfds < 0 && errno != EINTR) error_system_call (errno, syscall_select); @@ -817,6 +819,8 @@ OS_test_select_registry (select_registry_t registry, int blockp) 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); @@ -852,8 +856,8 @@ OS_test_select_descriptor (int fd, int blockp, unsigned int mode) return (SELECT_PROCESS_STATUS_CHANGE); if (pending_interrupts_p ()) return (SELECT_INTERRUPT); - /* nfds == 0, AND no status-change nor interrupts pending */ - return (0); + if (nfds == 0) /* and no status-change nor interrupts pending */ + return (0); } #else error_system_call (ENOSYS, syscall_select); -- 2.25.1