mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
server: stop wl_display event loop from any context
Calling wl_display_terminate() will exit the wl_display event loop at the start of the next loop iteration. This works fine when wl_display_terminate() is called after the event loop wakes up from polling on the added event sources. If, however, it is called before polling starts, the event loop will not exit until one or more event sources trigger. Depending on the types of event sources, they may never trigger (or may not trigger for a long time), so the event loop may never exit. Add an extra event source to the wl_display event loop that will trigger whenever wl_display_terminate() is called, so that the event loop will always exit. Fixes #201 Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
This commit is contained in:
parent
c6c1bbe4ab
commit
d564823cfd
2 changed files with 65 additions and 0 deletions
|
|
@ -1629,3 +1629,24 @@ TEST(global_remove)
|
|||
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
static void
|
||||
terminate_display(void *arg)
|
||||
{
|
||||
struct wl_display *wl_display = arg;
|
||||
wl_display_terminate(wl_display);
|
||||
}
|
||||
|
||||
TEST(no_source_terminate)
|
||||
{
|
||||
struct display *d;
|
||||
struct wl_event_loop *loop;
|
||||
|
||||
d = display_create();
|
||||
loop = wl_display_get_event_loop(d->wl_display);
|
||||
|
||||
wl_event_loop_add_idle(loop, terminate_display, d->wl_display);
|
||||
|
||||
display_run(d);
|
||||
display_destroy(d);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue