From 93eb41c020ccd11a8905a0e26e6dda74fff4ea3a Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sun, 12 Aug 2018 15:26:01 +0200 Subject: dconf_gdbus_get_worker_context(): improve GObject deadlock workaround The existing workaround for https://bugzilla.gnome.org/show_bug.cgi?id=674885 doesn't go far enough, and deadlocks can occur, for example, with the GSocket type. Extend the workaround logic to all the types from glib/gio/gdbusprivate.c:ensure_required_types(). --- gdbus/dconf-gdbus-thread.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gdbus/dconf-gdbus-thread.c b/gdbus/dconf-gdbus-thread.c index 8ed28b5..8b8f048 100644 --- a/gdbus/dconf-gdbus-thread.c +++ b/gdbus/dconf-gdbus-thread.c @@ -94,9 +94,28 @@ dconf_gdbus_get_worker_context (void) { GMainContext *context; - /* Work around https://bugzilla.gnome.org/show_bug.cgi?id=674885 */ + /* Work around https://bugzilla.gnome.org/show_bug.cgi?id=674885 + * + * This set of types is the same as the set in + * glib/gio/gdbusprivate.c:ensure_required_types(). That workaround + * is ineffective for us since we're already in the worker thread when + * we call g_bus_get_sync() and ensure_required_types() runs. So we do + * something similar here before launching the worker thread. Calling + * g_bus_get_sync() here would also be possible, but potentially would + * cause significant startup latency for every dconf user. + */ + g_type_ensure (G_TYPE_TASK); + g_type_ensure (G_TYPE_MEMORY_INPUT_STREAM); + g_type_ensure (G_TYPE_DBUS_CONNECTION_FLAGS); + g_type_ensure (G_TYPE_DBUS_CAPABILITY_FLAGS); + g_type_ensure (G_TYPE_DBUS_AUTH_OBSERVER); g_type_ensure (G_TYPE_DBUS_CONNECTION); g_type_ensure (G_TYPE_DBUS_PROXY); + g_type_ensure (G_TYPE_SOCKET_FAMILY); + g_type_ensure (G_TYPE_SOCKET_TYPE); + g_type_ensure (G_TYPE_SOCKET_PROTOCOL); + g_type_ensure (G_TYPE_SOCKET_ADDRESS); + g_type_ensure (G_TYPE_SOCKET); context = g_main_context_new (); g_thread_new ("dconf worker", dconf_gdbus_worker_thread, context); -- cgit v1.2.1