diff options
Diffstat (limited to 'queue_epoll.c')
-rw-r--r-- | queue_epoll.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/queue_epoll.c b/queue_epoll.c index 4721a9b..14bc355 100644 --- a/queue_epoll.c +++ b/queue_epoll.c @@ -103,7 +103,8 @@ struct mog_queue * mog_queue_new(void) return mog_queue_init(epoll_fd); } -static struct mog_fd * epoll_event_check(int rc, struct epoll_event *event) +static struct mog_fd * +epoll_event_check(int rc, struct epoll_event *event, bool cancellable) { struct mog_fd *mfd; @@ -119,6 +120,10 @@ static struct mog_fd * epoll_event_check(int rc, struct epoll_event *event) if (errno != EINTR) /* rc could be > 1 if the kernel is broken :P */ die_errno("epoll_wait() failed with (%d)", rc); + + if (cancellable) + mog_testcancel(); + return NULL; } @@ -134,14 +139,12 @@ struct mog_fd * mog_idleq_wait(struct mog_queue *q, int timeout) bool cancellable = timeout != 0; if (cancellable) - mog_cancel_enable(); + mog_testcancel(); /* epoll_wait is a cancellation point since glibc 2.4 */ rc = epoll_wait(q->queue_fd, &event, 1, timeout); - if (cancellable) - mog_cancel_disable(); - return epoll_event_check(rc, &event); + return epoll_event_check(rc, &event, cancellable); } struct mog_fd * mog_idleq_wait_intr(struct mog_queue *q, int timeout) @@ -150,7 +153,7 @@ struct mog_fd * mog_idleq_wait_intr(struct mog_queue *q, int timeout) struct epoll_event event; rc = epoll_pwait(q->queue_fd, &event, 1, timeout, &mog_emptyset); - return epoll_event_check(rc, &event); + return epoll_event_check(rc, &event, false); } MOG_NOINLINE static void |