mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
GDBusConnection: Avoid callbacks on finalized connection
Turns out that GDBusWorker will issue callbacks (in its own thread) even after g_dbus_worker_stop() has been called. This would rarely happen (and unreffing a connection is even rarer) so only saw this bug occasionally when running the gdbus-connection test case in a loop. Fix up this issue by maintaining a set of GDBusConnection objects that are currently "alive" and do nothing in the callbacks if the passed user_data pointer is not in this set. Also attempted to fix up a race condition with _g_object_wait_for_single_ref_do() and its use of GObject toggle references - for now, just resort to busy waiting, thereby sidestepping the toggle reference mess altogether. Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
@@ -116,13 +116,13 @@ test_connection_life_cycle (void)
|
||||
g_assert (!g_dbus_error_is_remote_error (error));
|
||||
g_assert (c == NULL);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
|
||||
/*
|
||||
* Check for correct behavior when a bus is present
|
||||
*/
|
||||
session_bus_up ();
|
||||
/* case 1 */
|
||||
error = NULL;
|
||||
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (c != NULL);
|
||||
@@ -131,6 +131,7 @@ test_connection_life_cycle (void)
|
||||
/*
|
||||
* Check that singleton handling work
|
||||
*/
|
||||
error = NULL;
|
||||
c2 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (c2 != NULL);
|
||||
@@ -1070,12 +1071,13 @@ test_connection_basic (void)
|
||||
g_assert (exit_on_close);
|
||||
g_assert (flags == G_DBUS_CAPABILITY_FLAGS_NONE ||
|
||||
flags == G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
||||
|
||||
g_object_unref (stream);
|
||||
g_object_unref (connection);
|
||||
g_free (name);
|
||||
g_free (guid);
|
||||
|
||||
_g_object_wait_for_single_ref (connection);
|
||||
g_object_unref (connection);
|
||||
|
||||
session_bus_down ();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user