From c1b8059bc2be24734013edb042639195b4efb8c2 Mon Sep 17 00:00:00 2001 From: Waldemar Kozaczuk Date: Sat, 1 Jun 2019 23:26:14 -0400 Subject: [PATCH] Provide full implementation of epoll_pwait This patch provides full implementation of epoll_pwait and exposes it as a public function which is needed by Node.JS 10. The implementation is modeled after pselect/select. Signed-off-by: Waldemar Kozaczuk Message-Id: <20190602032614.14827-1-jwkozaczuk@gmail.com> --- core/epoll.cc | 11 +++++++++++ linux.cc | 14 +------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/core/epoll.cc b/core/epoll.cc index 71530483c2..3978d19d78 100644 --- a/core/epoll.cc +++ b/core/epoll.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -338,6 +339,16 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout_ return epo->wait(events, maxevents, timeout_ms); } +int epoll_pwait(int epfd, struct epoll_event *events, int maxevents, int timeout_ms, + const sigset_t *sigmask) +{ + sigset_t origmask; + sigprocmask(SIG_SETMASK, sigmask, &origmask); + auto ret = epoll_wait(epfd, events, maxevents, timeout_ms); + sigprocmask(SIG_SETMASK, &origmask, NULL); + return ret; +} + void epoll_file_closed(epoll_ptr ptr) { ptr.epoll->del(ptr.key); diff --git a/linux.cc b/linux.cc index 420feba634..2892ede06b 100644 --- a/linux.cc +++ b/linux.cc @@ -353,18 +353,6 @@ static int pselect6(int nfds, fd_set *readfds, fd_set *writefds, return pselect(nfds, readfds, writefds, exceptfds, timeout_ts, NULL); } -static int epoll_pwait(int epfd, struct epoll_event *events, int maxevents, - int timeout_ms, void *sig) -{ - if(sig) { - WARN_ONCE("epoll_pwait(): unimplemented with not-null sigmask\n"); - errno = ENOSYS; - return -1; - } - - return epoll_wait(epfd, events, maxevents, timeout_ms); -} - long syscall(long number, ...) { // Save FPU state and restore it at the end of this function @@ -424,7 +412,7 @@ long syscall(long number, ...) SYSCALL4(pread64, int, void *, size_t, off_t); SYSCALL2(ftruncate, int, off_t); SYSCALL1(fsync, int); - SYSCALL5(epoll_pwait, int, struct epoll_event *, int, int, void*); + SYSCALL5(epoll_pwait, int, struct epoll_event *, int, int, const sigset_t*); SYSCALL3(getrandom, char *, size_t, unsigned int); SYSCALL2(nanosleep, const struct timespec*, struct timespec *); SYSCALL4(fstatat, int, const char *, struct stat *, int);