Use non-blocking timerfd to prevent blocking when updating timer event sources
authorAndrew Wedgbury <andrew.wedgbury@realvnc.com>
Fri, 25 Apr 2014 14:00:54 +0000 (15:00 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 25 Apr 2014 21:38:22 +0000 (14:38 -0700)
commit3e962728bf547de6316b5a01f40b38e55d3871cf
treedb4fd318c2d84a79aedf0cee7aff16400afbe12d
parent74df22befefa7e4ac2bd86ea0472347175b95ad1
Use non-blocking timerfd to prevent blocking when updating timer event sources

This implements a simple fix for the blocking problem that occurs when
updating a timer event source after the timer expires, but before its
callback is dispatched. This can happen when another event happens during the
same epoll wakeup as the timer event, and causes the read() call in
wl_event_source_timer_dispatch() to block for the updated duration of the
timer.

We never want this read() call to block, so I believe it makes sense for the
timerfd to be non-blocking, and we simply ignore the case where the read fails
with EAGAIN. We still report all other errors as before, and still ignore the
actual value read from the socket.

With this change, the event_loop_timer_updates unit test case I submitted
previously now passes, and weston appears to work as before.
src/event-loop.c