diff options
author | Philip Withnall <pwithnall@endlessos.org> | 2021-06-15 12:57:00 +0100 |
---|---|---|
committer | Philip Withnall <pwithnall@endlessos.org> | 2021-06-15 13:01:28 +0100 |
commit | 8530a6a8e4d19c9e6eb238f6b9b0462a70df188d (patch) | |
tree | 6759df9a6581cde66019a338c0b3a17eb9e5410a | |
parent | de74a70b7e1ab0c0f380248c1524f0bfad3d852b (diff) | |
download | glib-8530a6a8e4d19c9e6eb238f6b9b0462a70df188d.tar.gz |
tests: Add missing wakeup calls to gdbus-names test
The tests in `gdbus-names.c` use a mixture of `GMainLoop` and iterating
a `GMainContext` directly. Some of the helper functions based around the
`OwnNameData` struct use the `loop` `GMainLoop` even when called from
tests like `watch_with_different_context()` which themselves use
`GMainContext` directly.
Thus, it’s possible for the `GMainLoop` to not be running, while the
test is iterating on `g_main_context_iteration()`. In this case,
`g_main_loop_quit()` is a no-op and will not wake up the `GMainContext`.
This causes the test to livelock in around 1 in 1200 test runs.
Fix this by adding an explicit `g_main_context_wakeup()` call after each
`g_main_loop_quit()` call. A more comprehensive fix would be to port all
the tests in this file to iterating `GMainContext` directly, and drop
all the `GMainLoop` usage, but I don’t have time for that right now.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r-- | gio/tests/gdbus-names.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gio/tests/gdbus-names.c b/gio/tests/gdbus-names.c index 89bccb83d..26b7aa8e2 100644 --- a/gio/tests/gdbus-names.c +++ b/gio/tests/gdbus-names.c @@ -46,6 +46,7 @@ own_name_data_free_func (OwnNameData *data) { data->num_free_func++; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -57,6 +58,7 @@ bus_acquired_handler (GDBusConnection *connection, g_dbus_connection_set_exit_on_close (connection, FALSE); data->num_bus_acquired += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -67,6 +69,7 @@ name_acquired_handler (GDBusConnection *connection, OwnNameData *data = user_data; data->num_acquired += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -86,6 +89,7 @@ name_lost_handler (GDBusConnection *connection, } data->num_lost += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -516,6 +520,7 @@ watch_name_data_free_func (WatchNameData *data) { data->num_free_func++; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -533,6 +538,7 @@ w_name_acquired_handler (GDBusConnection *connection, OwnNameData *data = user_data; data->num_acquired += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -543,6 +549,7 @@ w_name_lost_handler (GDBusConnection *connection, OwnNameData *data = user_data; data->num_lost += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -564,6 +571,7 @@ name_appeared_handler (GDBusConnection *connection, } data->num_appeared += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } static void @@ -584,6 +592,7 @@ name_vanished_handler (GDBusConnection *connection, } data->num_vanished += 1; g_main_loop_quit (loop); + g_main_context_wakeup (g_main_loop_get_context (loop)); } typedef struct |