From 93ae78af91dbb5b3667aef97e9dff749910b95f7 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 12 Dec 2017 16:32:55 -0700 Subject: [PATCH] rktio: better ltps checking for epoll support Don't report ltps success for file descriptors that are not supported by epoll. Racket ports probably were not affected, since Racket doesn't try ltps registration for regular files or devices like /dev/null that report always being ready. --- racket/src/rktio/rktio_ltps.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/racket/src/rktio/rktio_ltps.c b/racket/src/rktio/rktio_ltps.c index 4c37afef26..7f123331b7 100644 --- a/racket/src/rktio/rktio_ltps.c +++ b/racket/src/rktio/rktio_ltps.c @@ -343,7 +343,17 @@ rktio_ltps_handle_t *rktio_ltps_add(rktio_t *rktio, rktio_ltps_t *lt, rktio_fd_t ev.events = EPOLLIN | (already ? EPOLLOUT : 0); kr = epoll_ctl(lt->fd, (already ? EPOLL_CTL_MOD : EPOLL_CTL_ADD), fd, &ev); - log_kqueue_error("read", kr); + if ((kr < 0) && (errno == EPERM)) { + /* not supported on this fd */ + v->read_handle = NULL; + if (!v->write_handle) { + ltps_hash_remove(lt, fd); + free(v); + } + free(s); + s = NULL; + } else + log_kqueue_error("read", kr); } # else RKTIO_FD_SET(fd, r); @@ -380,7 +390,17 @@ rktio_ltps_handle_t *rktio_ltps_add(rktio_t *rktio, rktio_ltps_t *lt, rktio_fd_t ev.events = EPOLLOUT | (already ? EPOLLIN : 0); kr = epoll_ctl(lt->fd, (already ? EPOLL_CTL_MOD : EPOLL_CTL_ADD), fd, &ev); - log_kqueue_error("write", kr); + if ((kr < 0) && (errno == EPERM)) { + /* not supported on this fd */ + v->write_handle = NULL; + if (!v->read_handle) { + ltps_hash_remove(lt, fd); + free(v); + } + free(s); + s = NULL; + } else + log_kqueue_error("write", kr); } # else RKTIO_FD_SET(fd, w);