mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
gio/tests/tls-interaction: fix two sporadic errors
The threaded tests are using the default main context in the worker thread, but were not g_main_context_acquire()ing it first, which meant that g_tls_interaction_invoke_ask_password() in the main thread would sometimes succeed in acquiring it itself and thus performing the operation in the wrong thread. Fix that. Also, we can't unref the loop from the worker thread, because the main thread isn't holding a reference on it, and so it might end up being destroyed while that thread is still inside g_main_loop_quit().
This commit is contained in:
parent
655c9f5753
commit
15f1ba4721
@ -409,14 +409,14 @@ thread_loop (gpointer user_data)
|
||||
g_assert (test->loop == NULL);
|
||||
test->loop = g_main_loop_new (context, TRUE);
|
||||
|
||||
g_main_context_acquire (context);
|
||||
g_cond_signal (closure->loop_started);
|
||||
g_mutex_unlock (closure->loop_mutex);
|
||||
|
||||
while (g_main_loop_is_running (test->loop))
|
||||
g_main_context_iteration (context, TRUE);
|
||||
|
||||
g_main_loop_unref (test->loop);
|
||||
test->loop = NULL;
|
||||
g_main_context_release (context);
|
||||
return test;
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ teardown_with_thread_loop (Test *test,
|
||||
g_assert (check == test);
|
||||
test->loop_thread = NULL;
|
||||
|
||||
g_assert (test->loop == NULL);
|
||||
g_main_loop_unref (test->loop);
|
||||
|
||||
teardown_without_loop (test, unused);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user