mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-23 20:46:14 +01:00
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>
This commit is contained in:
parent
de74a70b7e
commit
8530a6a8e4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user