From d5df5fb5b8f5e2815405a76ced4b7407988af0d6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 31 May 2014 08:09:36 +0200 Subject: Fix poll race condition on *BSD --- src/poll.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/poll.c') diff --git a/src/poll.c b/src/poll.c index a74d249..3756162 100644 --- a/src/poll.c +++ b/src/poll.c @@ -139,7 +139,7 @@ void fastd_poll_handle(void) { struct epoll_event events[16]; int ret = epoll_pwait(ctx.epoll_fd, events, 16, timeout, &set); if (ret < 0 && errno != EINTR) - exit_errno("epoll_wait"); + exit_errno("epoll_pwait"); fastd_update_time(); @@ -253,18 +253,9 @@ void fastd_poll_handle(void) { sigemptyset(&set); pthread_sigmask(SIG_SETMASK, &set, &oldset); - int ret = -1; - - if (!fastd_signalled()) { - /* - There is a race condition here: if a signal occurs after the fastd_signalled() check, but before the poll - call, poll() will be called with its normal timeout, potentially delaying the actual signal handling. On - OpenBSD we could use ppoll() to fix this, but on FreeBSD we're out of luck. - */ - ret = poll(VECTOR_DATA(ctx.pollfds), VECTOR_LEN(ctx.pollfds), timeout); - if (ret < 0 && errno != EINTR) - exit_errno("poll"); - } + int ret = poll(VECTOR_DATA(ctx.pollfds), VECTOR_LEN(ctx.pollfds), timeout); + if (ret < 0 && errno != EINTR) + exit_errno("poll"); pthread_sigmask(SIG_SETMASK, &oldset, NULL); fastd_update_time(); -- cgit v1.2.3