Skip to content

Commit 861de3d

Browse files
Michael Hudson-Doylesaghul
authored andcommitted
linux: try epoll_pwait if epoll_wait is missing
It seems that epoll_wait is implemented in glibc in terms of epoll_pwait and new architectures (like arm64) do not implement the epoll_wait syscall at all. So if epoll_wait errors with ENOSYS, just call epoll_pwait.
1 parent 5ccdfc5 commit 861de3d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/unix/linux-core.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
149149
int fd;
150150
int op;
151151
int i;
152+
static int no_epoll_wait;
152153

153154
if (loop->nfds == 0) {
154155
assert(QUEUE_EMPTY(&loop->watcher_queue));
@@ -195,10 +196,22 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
195196
count = 48; /* Benchmarks suggest this gives the best throughput. */
196197

197198
for (;;) {
198-
nfds = uv__epoll_wait(loop->backend_fd,
199-
events,
200-
ARRAY_SIZE(events),
201-
timeout);
199+
if (!no_epoll_wait) {
200+
nfds = uv__epoll_wait(loop->backend_fd,
201+
events,
202+
ARRAY_SIZE(events),
203+
timeout);
204+
if (nfds == -1 && errno == ENOSYS) {
205+
no_epoll_wait = 1;
206+
continue;
207+
}
208+
} else {
209+
nfds = uv__epoll_pwait(loop->backend_fd,
210+
events,
211+
ARRAY_SIZE(events),
212+
timeout,
213+
NULL);
214+
}
202215

203216
/* Update loop->time unconditionally. It's tempting to skip the update when
204217
* timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the

0 commit comments

Comments
 (0)