From fa0b08ff5ad97c74fdf2a8820563bc130629b2fc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 25 Dec 2014 14:43:54 +0100 Subject: [PATCH 1/3] linux: fix epoll_pwait() sigmask size calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revisit the fix from commit b705b53. The problem with using sigset_t and _NSIG is that the size of sigset_t and the value of _NSIG depend on what headers libuv picks up first, or . With the former, sizeof(sigset_t) = 128; with the latter, it's 8. Simply sidestep the issue by calculating the signal mask as a 64 bits integer, without using sigset_t or _NSIG. This is a partial cherry-pick of commit 751ac48 from the v1.x branch. Original PR-URL: https://github.com/libuv/libuv/pull/83 PR-URL: https://github.com/libuv/libuv/pull/84 Reviewed-By: Saúl Ibarra Corretgé --- src/unix/linux-core.c | 17 ++++++----------- src/unix/linux-syscalls.c | 6 +++--- src/unix/linux-syscalls.h | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c index 47938f2b..86c74caa 100644 --- a/src/unix/linux-core.c +++ b/src/unix/linux-core.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -131,8 +130,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { struct uv__epoll_event e; ngx_queue_t* q; uv__io_t* w; - sigset_t* pset; - sigset_t set; + uint64_t sigmask; uint64_t base; uint64_t diff; int nevents; @@ -183,24 +181,21 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { w->events = w->pevents; } - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } + sigmask = 0; + if (loop->flags & UV_LOOP_BLOCK_SIGPROF) + sigmask |= 1 << (SIGPROF - 1); assert(timeout >= -1); base = loop->time; count = 48; /* Benchmarks suggest this gives the best throughput. */ for (;;) { - if (no_epoll_wait || pset != NULL) { + if (no_epoll_wait || sigmask) { nfds = uv__epoll_pwait(loop->backend_fd, events, ARRAY_SIZE(events), timeout, - pset); + sigmask); } else { nfds = uv__epoll_wait(loop->backend_fd, events, diff --git a/src/unix/linux-syscalls.c b/src/unix/linux-syscalls.c index c9945438..267915d8 100644 --- a/src/unix/linux-syscalls.c +++ b/src/unix/linux-syscalls.c @@ -291,15 +291,15 @@ int uv__epoll_pwait(int epfd, struct uv__epoll_event* events, int nevents, int timeout, - const sigset_t* sigmask) { + uint64_t sigmask) { #if defined(__NR_epoll_pwait) return syscall(__NR_epoll_pwait, epfd, events, nevents, timeout, - sigmask, - _NSIG / 8); + &sigmask, + sizeof(sigmask)); #else return errno = ENOSYS, -1; #endif diff --git a/src/unix/linux-syscalls.h b/src/unix/linux-syscalls.h index 62eb5c5a..7be73bb6 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, - const sigset_t* sigmask); + uint64_t sigmask); int uv__eventfd2(unsigned int count, int flags); int uv__inotify_init(void); int uv__inotify_init1(int flags); From 378de30c59aef5fdb6d130fa5cfcb0a68fce571c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Mon, 5 Jan 2015 20:10:43 +0100 Subject: [PATCH 2/3] 2015.01.06, Version 0.10.32 (Stable) Changes since version 0.10.31: * linux: fix epoll_pwait() sigmask size calculation (Ben Noordhuis) --- ChangeLog | 7 +++++++ src/version.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8032c118..3083dc55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015.01.06, Version 0.10.32 (Stable) + +Changes since version 0.10.31: + +* linux: fix epoll_pwait() sigmask size calculation (Ben Noordhuis) + + 2014.12.25, Version 0.10.31 (Stable), 4dbd27e2219069a6daa769fb37f98673b77b4261 Changes since version 0.10.30: diff --git a/src/version.c b/src/version.c index 05d22240..99e39521 100644 --- a/src/version.c +++ b/src/version.c @@ -35,7 +35,7 @@ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 10 #define UV_VERSION_PATCH 32 -#define UV_VERSION_IS_RELEASE 0 +#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \ From 8d07ddb8c263ac2172d99b8214608edf800fb4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Mon, 5 Jan 2015 20:10:50 +0100 Subject: [PATCH 3/3] Now working on v0.10.33 --- ChangeLog | 2 +- src/version.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3083dc55..02a866d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2015.01.06, Version 0.10.32 (Stable) +2015.01.06, Version 0.10.32 (Stable), 378de30c59aef5fdb6d130fa5cfcb0a68fce571c Changes since version 0.10.31: diff --git a/src/version.c b/src/version.c index 99e39521..bca13b14 100644 --- a/src/version.c +++ b/src/version.c @@ -34,8 +34,8 @@ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 10 -#define UV_VERSION_PATCH 32 -#define UV_VERSION_IS_RELEASE 1 +#define UV_VERSION_PATCH 33 +#define UV_VERSION_IS_RELEASE 0 #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \