summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@cl.no>2013-02-26 02:43:37 +0100
committerBertrand Lorentz <bertrand.lorentz@gmail.com>2013-04-07 15:23:38 +0200
commitf9b90f3e50122d86b9fbb07072b7c1e8feef6c09 (patch)
treef427732d388fb38ec6369888b2b3e0006e60a6d6
parentac6c2f49ca8fb0554e5f35a920be4e9eeba17819 (diff)
Avoid race when using GConf and DBus with threads (bgo#692374)
GConf causes us to make indirect calls to libdbus from multiple threads, resulting in crashes if threads are not initialized explictly. As a workaround, we initialize dbus-glib for multithreading. This fixes adds an optional build-time dependency on dbus-glib, and will only be enabled if that dependency is satisfied. Some distros have addressed this issue by patching the underlying llibraries (gconf or gconf-sharp), so they don't have to enable that fix. But it should not conflict with those patches, as dbus_g_thread_init can be called multiple time, contrary to what the API documentation says. Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
-rw-r--r--build/m4/banshee/gconf.m48
-rw-r--r--src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs11
-rw-r--r--src/Core/Banshee.ThickClient/Banshee.ThickClient.dll.config3
-rw-r--r--src/Core/Banshee.ThickClient/Makefile.am6
4 files changed, 28 insertions, 0 deletions
diff --git a/build/m4/banshee/gconf.m4 b/build/m4/banshee/gconf.m4
index 16239dbcd..fbf1ce679 100644
--- a/build/m4/banshee/gconf.m4
+++ b/build/m4/banshee/gconf.m4
@@ -9,4 +9,12 @@ AC_DEFUN([BANSHEE_CHECK_GCONF],
m4_pattern_allow([AM_GCONF_SOURCE_2])
AM_GCONF_SOURCE_2
+
+ # dbus-glib is needed for the workaround for bgo#692374
+ PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= 0.80, have_dbus_glib="yes", have_dbus_glib="no")
+ if test "x$have_dbus_glib" = "xyes"; then
+ AM_CONDITIONAL(HAVE_DBUS_GLIB, true)
+ else
+ AM_CONDITIONAL(HAVE_DBUS_GLIB, false)
+ fi
])
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
index c5c567582..c3891c1a1 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
@@ -28,6 +28,7 @@
using System;
using System.IO;
+using System.Runtime.InteropServices;
using Mono.Addins;
@@ -100,6 +101,9 @@ namespace Banshee.Gui
{
}
+ [DllImport ("libdbus-glib-1-2.dll")]
+ internal static extern void dbus_g_thread_init ();
+
protected virtual void InitializeGtk ()
{
Log.Debug ("Initializing GTK");
@@ -107,6 +111,13 @@ namespace Banshee.Gui
if (!GLib.Thread.Supported) {
GLib.Thread.Init ();
}
+
+#if HAVE_DBUS_GLIB
+ // Using GConf from multiple threads causes crashes if multithreading is not initialized explictly in dbus
+ // This is a workaround for bgo#692374
+ dbus_g_thread_init ();
+#endif
+
Gtk.Application.Init ();
if (ApplicationContext.CommandLine.Contains ("debug-gtkrc")) {
diff --git a/src/Core/Banshee.ThickClient/Banshee.ThickClient.dll.config b/src/Core/Banshee.ThickClient/Banshee.ThickClient.dll.config
new file mode 100644
index 000000000..d69fdc85d
--- /dev/null
+++ b/src/Core/Banshee.ThickClient/Banshee.ThickClient.dll.config
@@ -0,0 +1,3 @@
+<configuration>
+ <dllmap dll="libdbus-glib-1-2.dll" target="libdbus-glib-1.so.2"/>
+</configuration>
diff --git a/src/Core/Banshee.ThickClient/Makefile.am b/src/Core/Banshee.ThickClient/Makefile.am
index 5eeaff2a5..bdcea43c4 100644
--- a/src/Core/Banshee.ThickClient/Makefile.am
+++ b/src/Core/Banshee.ThickClient/Makefile.am
@@ -3,6 +3,10 @@ TARGET = library
ASSEMBLY_BUILD_FLAGS = -unsafe
LINK = $(REF_BANSHEE_THICKCLIENT)
+if HAVE_DBUS_GLIB
+BUILD_DEFINES = "-define:HAVE_DBUS_GLIB"
+endif
+
SOURCES = \
Banshee.Addins.Gui/AddinView.cs \
Banshee.CairoGlyphs/BansheeLineLogo.cs \
@@ -174,3 +178,5 @@ RESOURCES = \
include $(top_srcdir)/build/build.mk
+EXTRA_DIST += Banshee.ThickClient.dll.config
+module_SCRIPTS += Banshee.ThickClient.dll.config