From: Matt Birkholz Date: Fri, 19 Oct 2012 18:52:04 +0000 (-0700) Subject: Fix test-select-descriptor, test-select-registry. X-Git-Tag: mit-scheme-pucked-9.2.12~552 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=9d566d67fd3cfcc99752eea0519ad8451e584c71;p=mit-scheme.git 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). --- 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);