diff --git a/gio/tests/socket-service.c b/gio/tests/socket-service.c index a5d114f29..dc8bdec23 100644 --- a/gio/tests/socket-service.c +++ b/gio/tests/socket-service.c @@ -139,6 +139,12 @@ connection_cb (GThreadedSocketService *service, GObject *source_object, gpointer user_data) { + GMainLoop *loop = user_data; + + /* Since the connection attempt has come through to be handled, stop the main + * thread waiting for it; this causes the #GSocketService to be stopped. */ + g_main_loop_quit (loop); + /* Block until the main thread has dropped its ref to @service, so that we * will drop the final ref from this thread. */ @@ -158,7 +164,6 @@ client_connected_cb (GObject *client, GAsyncResult *result, gpointer user_data) { - GMainLoop *loop = user_data; GSocketConnection *conn; GError *error = NULL; @@ -166,7 +171,6 @@ client_connected_cb (GObject *client, g_assert_no_error (error); g_object_unref (conn); - g_main_loop_quit (loop); } static void @@ -195,9 +199,8 @@ test_threaded_712570 (void) g_assert_no_error (error); g_object_unref (addr); - g_signal_connect (service, "run", G_CALLBACK (connection_cb), NULL); - loop = g_main_loop_new (NULL, FALSE); + g_signal_connect (service, "run", G_CALLBACK (connection_cb), loop); client = g_socket_client_new (); g_socket_client_connect_async (client,