From 020c28af111d7d0fc325fc9a55bd185368e049cd Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 9 Jan 2015 08:45:44 +0100 Subject: poll: directly call epoll_pwait syscall instead of using the libc wrapper There are systems without the wrapper (e.g. older Android versions), and the wrapper is broken in some versions of uClibc. --- src/poll.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/poll.c b/src/poll.c index 3419d05..085c05c 100644 --- a/src/poll.c +++ b/src/poll.c @@ -69,6 +69,15 @@ static inline int handshake_timeout(void) { #include #include +#include +#include + + +/** Simplified epoll_pwait wrapper (as there are systems without or with broken epoll_pwait) */ +static inline int epoll_wait_unblocked(int epfd, struct epoll_event *events, int maxevents, int timeout) { + const uint8_t buf[_NSIG/8] = {}; + return syscall(SYS_epoll_pwait, epfd, events, maxevents, timeout, buf, sizeof(buf)); +} void fastd_poll_init(void) { @@ -150,11 +159,8 @@ void fastd_poll_handle(void) { if (timeout < 0 || timeout > maintenance_timeout) timeout = maintenance_timeout; - sigset_t set; - sigemptyset(&set); - struct epoll_event events[16]; - int ret = epoll_pwait(ctx.epoll_fd, events, 16, timeout, &set); + int ret = epoll_wait_unblocked(ctx.epoll_fd, events, 16, timeout); if (ret < 0 && errno != EINTR) exit_errno("epoll_pwait"); -- cgit v1.2.3