~ chicken-core (chicken-5) 2a9696691c2792f981f0adfd46208d419eaad867
commit 2a9696691c2792f981f0adfd46208d419eaad867 Author: Peter Bex <peter.bex@xs4all.nl> AuthorDate: Tue Feb 26 18:58:45 2013 +0100 Commit: Mario Domenech Goulart <mario.goulart@gmail.com> CommitDate: Tue Feb 26 15:23:53 2013 -0300 When checking whether an FD is ready for input or output, also check for special situations (error, device/FIFO/pipe hangup and invalid FD) in the poll() implementation of the scheduler. This fixes a CPU consumption bug in waiting for process-ports on Linux (thanks to Mario Goulart for finding the bug). Signed-off-by: Mario Domenech Goulart <mario.goulart@gmail.com> diff --git a/NEWS b/NEWS index 226cc735..a5f90541 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ - Core libraries - read-line no longer returns trailing CRs in rare cases on TCP ports (#568) +- Runtime system + - Special events in poll() are now handled, avoiding hangs in threaded apps. + 4.8.1 - Security fixes diff --git a/scheduler.scm b/scheduler.scm index ff521a76..ee258fe4 100644 --- a/scheduler.scm +++ b/scheduler.scm @@ -85,8 +85,8 @@ C_inline int C_fd_ready(int fd, int pos, int what) { return(C_fdset_set[pos].revents & what); } -#define C_fd_input_ready(fd,pos) C_mk_bool(C_fd_ready(C_unfix(fd), C_unfix(pos),POLLIN)) -#define C_fd_output_ready(fd,pos) C_mk_bool(C_fd_ready(C_unfix(fd), C_unfix(pos),POLLOUT)) +#define C_fd_input_ready(fd,pos) C_mk_bool(C_fd_ready(C_unfix(fd), C_unfix(pos),POLLIN|POLLERR|POLLHUP|POLLNVAL)) +#define C_fd_output_ready(fd,pos) C_mk_bool(C_fd_ready(C_unfix(fd), C_unfix(pos),POLLOUT|POLLERR|POLLHUP|POLLNVAL)) C_inline int C_ready_fds_timeout(int to, double tm) { return poll(C_fdset_set, C_fdset_nfds, to ? (int)tm : -1);Trap