diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-01-09 08:45:44 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-01-09 08:54:08 +0100 |
commit | 020c28af111d7d0fc325fc9a55bd185368e049cd (patch) | |
tree | 205767a0071d2da40dc56cd297c9848975b09857 /src | |
parent | e5826e3c5a317f24c1c1e5b48cc6200e3f81edf2 (diff) | |
download | fastd-020c28af111d7d0fc325fc9a55bd185368e049cd.tar fastd-020c28af111d7d0fc325fc9a55bd185368e049cd.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/poll.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -69,6 +69,15 @@ static inline int handshake_timeout(void) { #include <fcntl.h> #include <sys/epoll.h> +#include <sys/signal.h> +#include <sys/syscall.h> + + +/** 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"); |