Skip to content

Instantly share code, notes, and snippets.

@lucab
Created May 12, 2015 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucab/d183232e8c8d45208b28 to your computer and use it in GitHub Desktop.
Save lucab/d183232e8c8d45208b28 to your computer and use it in GitHub Desktop.
diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
index 11a67eb..b96b44d 100644
--- a/src/unix/linux-core.c
+++ b/src/unix/linux-core.c
@@ -33,6 +33,7 @@
#include <sys/prctl.h>
#include <sys/sysinfo.h>
#include <unistd.h>
+#include <signal.h>
#include <fcntl.h>
#include <time.h>
@@ -133,9 +134,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
ngx_queue_t* q;
uv__io_t* w;
sigset_t sigset;
- uint64_t sigmask;
uint64_t base;
uint64_t diff;
+ int empty_sigset;
int nevents;
int count;
int nfds;
@@ -183,11 +184,11 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
w->events = w->pevents;
}
- sigmask = 0;
+ empty_sigset = 1;
if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {
sigemptyset(&sigset);
sigaddset(&sigset, SIGPROF);
- sigmask |= 1 << (SIGPROF - 1);
+ empty_sigset = 0;
}
assert(timeout >= -1);
@@ -195,16 +196,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
count = 48; /* Benchmarks suggest this gives the best throughput. */
for (;;) {
- if (sigmask != 0 && no_epoll_pwait != 0)
+ if (empty_sigset == 0 && no_epoll_pwait != 0)
if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
abort();
- if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) {
+ if (no_epoll_wait != 0 || (empty_sigset == 0 && no_epoll_pwait == 0)) {
nfds = uv__epoll_pwait(loop->backend_fd,
events,
ARRAY_SIZE(events),
timeout,
- sigmask);
+ &sigset);
if (nfds == -1 && errno == ENOSYS)
no_epoll_pwait = 1;
} else {
@@ -216,7 +217,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
no_epoll_wait = 1;
}
- if (sigmask != 0 && no_epoll_pwait != 0)
+ if (empty_sigset == 0 && no_epoll_pwait != 0)
if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL))
abort();
diff --git a/src/unix/linux-syscalls.c b/src/unix/linux-syscalls.c
index 267915d..7fe66a0 100644
--- a/src/unix/linux-syscalls.c
+++ b/src/unix/linux-syscalls.c
@@ -22,6 +22,7 @@
#include "linux-syscalls.h"
#include <unistd.h>
#include <signal.h>
+#include <sys/epoll.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <errno.h>
@@ -291,15 +292,13 @@ int uv__epoll_pwait(int epfd,
struct uv__epoll_event* events,
int nevents,
int timeout,
- uint64_t sigmask) {
+ const sigset_t* sigmask) {
#if defined(__NR_epoll_pwait)
- return syscall(__NR_epoll_pwait,
- epfd,
- events,
- nevents,
- timeout,
- &sigmask,
- sizeof(sigmask));
+ return epoll_pwait(epfd,
+ (struct epoll_event *) events,
+ nevents,
+ timeout,
+ sigmask);
#else
return errno = ENOSYS, -1;
#endif
diff --git a/src/unix/linux-syscalls.h b/src/unix/linux-syscalls.h
index 7be73bb..62eb5c5 100644
--- a/src/unix/linux-syscalls.h
+++ b/src/unix/linux-syscalls.h
@@ -130,7 +130,7 @@ int uv__epoll_pwait(int epfd,
struct uv__epoll_event* events,
int nevents,
int timeout,
- uint64_t sigmask);
+ const sigset_t* sigmask);
int uv__eventfd2(unsigned int count, int flags);
int uv__inotify_init(void);
int uv__inotify_init1(int flags);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment