Skip to content

Commit

Permalink
Provide full implementation of epoll_pwait
Browse files Browse the repository at this point in the history
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 <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
wkozaczuk authored and nyh committed Jun 2, 2019
1 parent e37d8ed commit c1b8059
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 11 additions & 0 deletions core/epoll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <memory>
#include <stdio.h>
#include <errno.h>
#include <signal.h>

#include <osv/file.h>
#include <osv/poll.h>
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 1 addition & 13 deletions linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c1b8059

Please sign in to comment.