[glib/wip/pwithnall/gdbus-names-livelock: 2/2] tests: Add missing wakeup calls to gdbus-names.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pwithnall/gdbus-names-livelock: 2/2] tests: Add missing wakeup calls to gdbus-names.c
- Date: Tue, 15 Jun 2021 12:01:39 +0000 (UTC)
commit 9f6cc0bd258409bdb041e5d9a1194a5238486d8e
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Jun 15 13:00:20 2021 +0100
tests: Add missing wakeup calls to gdbus-names.c
Following on from the previous commit, some explicit
`g_main_context_wakeup()` calls were missing from the test code which
only uses `GMainContext`.
Add them, and also add some assertions to check that these functions are
being called in the expected thread (as the code comments say).
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gio/tests/gdbus-names.c | 11 +++++++++++
1 file changed, 11 insertions(+)
---
diff --git a/gio/tests/gdbus-names.c b/gio/tests/gdbus-names.c
index 26b7aa8e2..00d9387a6 100644
--- a/gio/tests/gdbus-names.c
+++ b/gio/tests/gdbus-names.c
@@ -513,6 +513,7 @@ typedef struct
gboolean unwatch_early;
GMutex mutex;
guint watch_id;
+ GMainContext *thread_context; /* (owned) locked by mutex */
} WatchNameThreadData;
static void
@@ -892,6 +893,9 @@ static void
t_watch_name_data_free_func (WatchNameThreadData *thread_data)
{
thread_data->data.num_free_func++;
+
+ g_assert_true (g_main_context_is_owner (thread_data->thread_context));
+ g_main_context_wakeup (thread_data->thread_context);
}
/* Called in the same thread as watcher_thread() */
@@ -903,6 +907,9 @@ t_name_appeared_handler (GDBusConnection *connection,
{
WatchNameThreadData *thread_data = user_data;
thread_data->data.num_appeared += 1;
+
+ g_assert_true (g_main_context_is_owner (thread_data->thread_context));
+ g_main_context_wakeup (thread_data->thread_context);
}
/* Called in the same thread as watcher_thread() */
@@ -913,6 +920,9 @@ t_name_vanished_handler (GDBusConnection *connection,
{
WatchNameThreadData *thread_data = user_data;
thread_data->data.num_vanished += 1;
+
+ g_assert_true (g_main_context_is_owner (thread_data->thread_context));
+ g_main_context_wakeup (thread_data->thread_context);
}
/* Called in the thread which constructed the GDBusConnection */
@@ -940,6 +950,7 @@ watcher_thread (gpointer user_data)
GMainContext *thread_context;
thread_context = g_main_context_new ();
+ thread_data->thread_context = thread_context;
g_main_context_push_thread_default (thread_context);
// Notify that the thread has started
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]