From 05c82d877c8cb3b95649c72a69516cb89d2356ab Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 23 Jul 2019 11:00:05 -0600 Subject: [PATCH] rktio: fix problem with lazy ltps Don't try to wait on a kqueue or epoll fd that is not yet initialized. --- racket/src/rktio/rktio_poll_set.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/racket/src/rktio/rktio_poll_set.c b/racket/src/rktio/rktio_poll_set.c index 673c18a116..ee7066adf5 100644 --- a/racket/src/rktio/rktio_poll_set.c +++ b/racket/src/rktio/rktio_poll_set.c @@ -1243,8 +1243,11 @@ void rktio_sleep(rktio_t *rktio, float nsecs, rktio_poll_set_t *fds, rktio_ltps_ if (fds && lt) { #if defined(HAVE_KQUEUE_SYSCALL) || defined(HAVE_EPOLL_SYSCALL) int fd = rktio_ltps_get_fd(lt); - RKTIO_FD_SET(fd, fds); - RKTIO_FD_SET(fd, RKTIO_GET_FDSET(fds, 2)); + /* `fd` can be -1, because the file descriptor is created lazily */ + if (fd != -1) { + RKTIO_FD_SET(fd, fds); + RKTIO_FD_SET(fd, RKTIO_GET_FDSET(fds, 2)); + } #else rktio_merge_fd_sets(fds, rktio_ltps_get_fd_set(lt)); #endif