static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
int maxevents, long timeout)
{
- int res = 0, eavail, timed_out = 0;
+ int res, eavail, timed_out = 0;
u64 slack = 0;
wait_queue_entry_t wait;
ktime_t expires, *to = NULL;
ep_reset_busy_poll_napi_id(ep);
do {
+ if (signal_pending(current))
+ return -EINTR;
+
/*
* Internally init_wait() uses autoremove_wake_function(),
* thus wait entry is removed from the wait queue on each
* important.
*/
eavail = ep_events_available(ep);
- if (!eavail) {
- if (signal_pending(current))
- res = -EINTR;
- else
- __add_wait_queue_exclusive(&ep->wq, &wait);
- }
+ if (!eavail)
+ __add_wait_queue_exclusive(&ep->wq, &wait);
+
write_unlock_irq(&ep->lock);
- if (!eavail && !res)
+ if (!eavail)
timed_out = !schedule_hrtimeout_range(to, slack,
HRTIMER_MODE_ABS);
* finding more events available and fetching
* repeatedly.
*/
- res = -EINTR;
+ return -EINTR;
}
/*
* Try to transfer events to user space. In case we get 0 events and
* there's still timeout left over, we go trying again in search of
* more luck.
*/
- if (!res && eavail &&
+ if (eavail &&
!(res = ep_send_events(ep, events, maxevents)) && !timed_out)
goto fetch_events;