Skip to content

Commit c1b8059

Browse files
wkozaczuknyh
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]>
1 parent e37d8ed commit c1b8059

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

core/epoll.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <memory>
1313
#include <stdio.h>
1414
#include <errno.h>
15+
#include <signal.h>
1516

1617
#include <osv/file.h>
1718
#include <osv/poll.h>
@@ -338,6 +339,16 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout_
338339
return epo->wait(events, maxevents, timeout_ms);
339340
}
340341

342+
int epoll_pwait(int epfd, struct epoll_event *events, int maxevents, int timeout_ms,
343+
const sigset_t *sigmask)
344+
{
345+
sigset_t origmask;
346+
sigprocmask(SIG_SETMASK, sigmask, &origmask);
347+
auto ret = epoll_wait(epfd, events, maxevents, timeout_ms);
348+
sigprocmask(SIG_SETMASK, &origmask, NULL);
349+
return ret;
350+
}
351+
341352
void epoll_file_closed(epoll_ptr ptr)
342353
{
343354
ptr.epoll->del(ptr.key);

linux.cc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,6 @@ static int pselect6(int nfds, fd_set *readfds, fd_set *writefds,
353353
return pselect(nfds, readfds, writefds, exceptfds, timeout_ts, NULL);
354354
}
355355

356-
static int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
357-
int timeout_ms, void *sig)
358-
{
359-
if(sig) {
360-
WARN_ONCE("epoll_pwait(): unimplemented with not-null sigmask\n");
361-
errno = ENOSYS;
362-
return -1;
363-
}
364-
365-
return epoll_wait(epfd, events, maxevents, timeout_ms);
366-
}
367-
368356
long syscall(long number, ...)
369357
{
370358
// Save FPU state and restore it at the end of this function
@@ -424,7 +412,7 @@ long syscall(long number, ...)
424412
SYSCALL4(pread64, int, void *, size_t, off_t);
425413
SYSCALL2(ftruncate, int, off_t);
426414
SYSCALL1(fsync, int);
427-
SYSCALL5(epoll_pwait, int, struct epoll_event *, int, int, void*);
415+
SYSCALL5(epoll_pwait, int, struct epoll_event *, int, int, const sigset_t*);
428416
SYSCALL3(getrandom, char *, size_t, unsigned int);
429417
SYSCALL2(nanosleep, const struct timespec*, struct timespec *);
430418
SYSCALL4(fstatat, int, const char *, struct stat *, int);

0 commit comments

Comments
 (0)