struct select_registry_s * r = registry;
while (1)
{
- int nfds
- = (poll ((SR_ENTRIES (r)),
- (SR_N_FDS (r)),
- (blockp ? INFTIM : 0)));
- if (nfds > 0)
+ int nfds = (safe_poll ((SR_ENTRIES (r)), (SR_N_FDS (r)), blockp));
+ 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);
((pfds [0]) . events) = (DECODE_MODE (mode));
while (1)
{
- int nfds = (poll (pfds, 1, (blockp ? INFTIM : 0)));
+ 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);
{
#ifdef HAVE_SELECT
struct select_registry_s * r = registry;
+
+ (* (SR_RREADERS (r))) = (* (SR_QREADERS (r)));
+ (* (SR_RWRITERS (r))) = (* (SR_QWRITERS (r)));
while (1)
{
- int nfds;
-
- (* (SR_RREADERS (r))) = (* (SR_QREADERS (r)));
- (* (SR_RWRITERS (r))) = (* (SR_QWRITERS (r)));
- INTERRUPTABLE_EXTENT
- (nfds,
- ((OS_process_any_status_change ())
- ? ((errno = EINTR), (-1))
- : (UX_select (FD_SETSIZE,
- (SR_RREADERS (r)),
- (SR_RWRITERS (r)),
- 0,
- (blockp ? 0 : (&zero_timeout))))));
- if (nfds > 0)
+ int nfds = (safe_select (FD_SETSIZE,
+ (SR_RREADERS (r)),
+ (SR_RWRITERS (r)),
+ blockp));
+ 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);
condition
(within-continuation k thunk))
thunk))))))))
- (if (not io-registrations)
- (begin
- ;; Busy-waiting here is a bad idea -- should implement a
- ;; primitive to block the Scheme process while waiting for a
- ;; signal.
- (catch-errors
- (lambda ()
- (set-interrupt-enables! interrupt-mask/all)
- (do () (#f)))))
- (let ((result
- (catch-errors
- (lambda ()
- (%trace ";wait-for-io: blocking for i/o\n")
- (set-interrupt-enables! interrupt-mask/all)
- (test-select-registry io-registry #t)))))
- (set-interrupt-enables! interrupt-mask/gc-ok)
- (signal-select-result result)
- (let ((thread first-running-thread))
- (if thread
- (if (thread/continuation thread)
- (begin
- (%trace ";wait-for-io: running "thread"\n")
- (run-thread thread))
- (begin
- (%trace ";wait-for-io: continuing "thread"\n")
- (%maybe-toggle-thread-timer)))
+ (let ((result
+ (catch-errors
+ (lambda ()
++ (%trace ";wait-for-io: blocking for i/o\n")
+ (set-interrupt-enables! interrupt-mask/all)
+ (test-select-registry io-registry #t)))))
+ (set-interrupt-enables! interrupt-mask/gc-ok)
+ (signal-select-result result)
+ (let ((thread first-running-thread))
+ (if thread
+ (if (thread/continuation thread)
- (run-thread thread)
- (%maybe-toggle-thread-timer))
- (wait-for-io))))))
++ (begin
++ (%trace ";wait-for-io: running "thread"\n")
++ (run-thread thread))
+ (begin
- (%trace ";wait-for-io: looping\n")
- (wait-for-io))))))))
++ (%trace ";wait-for-io: continuing "thread"\n")
++ (%maybe-toggle-thread-timer)))
++ (begin
++ (%trace ";wait-for-io: looping\n")
++ (wait-for-io)))))))
\f
(define (signal-select-result result)
(cond ((vector? result)