summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamian Hobson-Garcia <dhobsong@igel.co.jp>2021-08-31 18:59:33 +0900
committerDaniel Stone <daniels@collabora.com>2021-10-09 13:09:04 +0000
commitd564823cfdbdb62e4d84a3b2d15fa016fd7fb5dd (patch)
treede6ee35439d0f90b071946ae368cf3957f0b7f3c /tests
parentc6c1bbe4abf9e5ce159442be22c1278d39844c08 (diff)
downloadwayland-d564823cfdbdb62e4d84a3b2d15fa016fd7fb5dd.tar.gz
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/display-test.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/display-test.c b/tests/display-test.c
index 3db7c95..763adc9 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -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);
+}