mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
g_test_dbus_down: Ensure next test does not use old connection
There's a race condition somewhere in GTestDBus that can result in the next test being started at a time when g_bus_get() would still return the connection that is in the process of closing. This can be reproduced reasonably reliably by running the gapplication test 10K times in a loop. Instead of relying on waiting for the weak reference to be released, we can force the issue by clearing it. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=768996 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=894677
This commit is contained in:
parent
b806df0ef1
commit
3d50691a30
@ -7233,6 +7233,22 @@ _g_bus_get_singleton_if_exists (GBusType bus_type)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* May be called from any thread. Must not hold message_bus_lock. */
|
||||
void
|
||||
_g_bus_forget_singleton (GBusType bus_type)
|
||||
{
|
||||
GWeakRef *singleton;
|
||||
|
||||
G_LOCK (message_bus_lock);
|
||||
|
||||
singleton = message_bus_get_singleton (bus_type, NULL);
|
||||
|
||||
if (singleton != NULL)
|
||||
g_weak_ref_set (singleton, NULL);
|
||||
|
||||
G_UNLOCK (message_bus_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_bus_get_sync:
|
||||
* @bus_type: a #GBusType
|
||||
|
@ -146,6 +146,7 @@ gchar *_g_dbus_hexencode (const gchar *str,
|
||||
|
||||
/* Implemented in gdbusconnection.c */
|
||||
GDBusConnection *_g_bus_get_singleton_if_exists (GBusType bus_type);
|
||||
void _g_bus_forget_singleton (GBusType bus_type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -823,6 +823,7 @@ g_test_dbus_down (GTestDBus *self)
|
||||
_g_object_dispose_and_wait_weak_notify (connection);
|
||||
|
||||
g_test_dbus_unset ();
|
||||
_g_bus_forget_singleton (G_BUS_TYPE_SESSION);
|
||||
self->priv->up = FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user