mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
gdbus: Initialize types earlier to break proxy <-> connection deadlock
This will help us break generic GType deadlocks between people using GDBus in different threads (which is supported), not just by GType usage in the GDBus thread. This should fix the common cases we're seeing in the wild, although I have some lingering concerns that if someone e.g. referenced e.g. `G_TYPE_DBUS_AUTH_MECHANISM_SHA1` etc. we'd need to add those too. https://bugzilla.gnome.org/show_bug.cgi?id=674885
This commit is contained in:
@@ -202,7 +202,8 @@ _g_socket_read_with_control_messages_finish (GSocket *socket,
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=627724 */
|
||||
/* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=674885
|
||||
and see also the original https://bugzilla.gnome.org/show_bug.cgi?id=627724 */
|
||||
|
||||
static GPtrArray *ensured_classes = NULL;
|
||||
|
||||
@@ -227,6 +228,8 @@ ensure_required_types (void)
|
||||
ensured_classes = g_ptr_array_new ();
|
||||
ensure_type (G_TYPE_TASK);
|
||||
ensure_type (G_TYPE_MEMORY_INPUT_STREAM);
|
||||
ensure_type (G_TYPE_DBUS_CONNECTION);
|
||||
ensure_type (G_TYPE_DBUS_PROXY);
|
||||
}
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
@@ -264,9 +267,6 @@ _g_dbus_shared_thread_ref (void)
|
||||
{
|
||||
SharedThreadData *data;
|
||||
|
||||
/* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=627724 */
|
||||
ensure_required_types ();
|
||||
|
||||
data = g_new0 (SharedThreadData, 1);
|
||||
data->refcount = 0;
|
||||
|
||||
@@ -1921,6 +1921,9 @@ _g_dbus_initialize (void)
|
||||
_gdbus_debug_flags |= G_DBUS_DEBUG_MESSAGE;
|
||||
}
|
||||
|
||||
/* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=627724 */
|
||||
ensure_required_types ();
|
||||
|
||||
g_once_init_leave (&initialized, 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user