tests: Use separate GMainContext in thread in spawn-multithreaded

Otherwise the `start_thread()` threads and the main thread are competing
to iterate the global default context, which is probably not what was
intended.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-03-12 01:30:00 +00:00
parent 54748d3b7c
commit ca99cf032d

View File

@ -112,8 +112,10 @@ start_thread (gpointer user_data)
GPid pid;
SpawnChildsData *data = user_data;
gint ttl = data->ttl;
GMainContext *new_main_context = NULL;
new_main_loop = g_main_loop_new (NULL, FALSE);
new_main_context = g_main_context_new ();
new_main_loop = g_main_loop_new (new_main_context, FALSE);
pid = get_a_child (ttl);
source = g_child_watch_source_new (pid);
@ -126,6 +128,7 @@ start_thread (gpointer user_data)
g_main_loop_run (new_main_loop);
g_main_loop_unref (new_main_loop);
g_main_context_unref (new_main_context);
return NULL;
}