From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master
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 <jwkozac...@gmail.com>
Message-Id: <20190602032614.14827-1-jwkozac...@gmail.com>
---
diff --git a/core/epoll.cc b/core/epoll.cc
--- a/core/epoll.cc
+++ b/core/epoll.cc
@@ -12,6 +12,7 @@
#include <memory>
#include <stdio.h>
#include <errno.h>
+#include <signal.h>
#include <osv/file.h>
#include <osv/poll.h>
@@ -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
--- 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);
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/osv-dev/0000000000000686bc058a538dfa%40google.com.
For more options, visit https://groups.google.com/d/optout.