event-loop: Dispatch idle callbacks twice
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 28 Jan 2015 15:25:03 +0000 (09:25 -0600)
committerBryce Harrington <bryce@osg.samsung.com>
Thu, 29 Jan 2015 02:12:31 +0000 (18:12 -0800)
commit5ec8062df26f21cfe7a031eaf83a1b4d99085f36
treec25d874a54fe9c85d401df9f55e64d18eef3c73d
parent7575e2ea19dcb6012a6fd4729197d12a68b89025
event-loop: Dispatch idle callbacks twice

To fix a shutdown crash in weston's x11 compositor I want to move the
weston X window close to an idle handler.

Since idle handlers are processed at the start of an event loop, the
handler that deals with window close will run at the start of the
next input_loop dispatch, after which the dispatcher blocks on epoll
forever (since all input events that will ever occur have been consumed).

Dispatching idle callbacks both at the start and end of event-loop
processing will prevent this permanent blocking.

Note that just moving the callback dispatch could theoretically
result in an idle callback being delayed indefinitely while waiting
for epoll_wait() to complete.

Callbacks are removed from the list when they're run, so the second
dispatch won't result in any extra calls.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
src/event-loop.c