From 5ec8062df26f21cfe7a031eaf83a1b4d99085f36 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 28 Jan 2015 09:25:03 -0600 Subject: [PATCH] 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 Reviewed-by: Giulio Camuffo Reviewed-by: Bryce Harrington --- src/event-loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/event-loop.c b/src/event-loop.c index 1f571ba4..d257d78c 100644 --- a/src/event-loop.c +++ b/src/event-loop.c @@ -421,10 +421,12 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout) wl_event_loop_process_destroy_list(loop); + wl_event_loop_dispatch_idle(loop); + do { n = post_dispatch_check(loop); } while (n > 0); - + return 0; }