[banshee] Avoid race when using GConf and DBus with threads (bgo#692374)
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Avoid race when using GConf and DBus with threads (bgo#692374)
- Date: Sun, 7 Apr 2013 13:40:21 +0000 (UTC)
commit f9b90f3e50122d86b9fbb07072b7c1e8feef6c09
Author: Hans Petter Jansson <hpj cl no>
Date: Tue Feb 26 02:43:37 2013 +0100
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>
build/m4/banshee/gconf.m4 | 8 ++++++++
.../Banshee.Gui/GtkBaseClient.cs | 11 +++++++++++
.../Banshee.ThickClient.dll.config | 3 +++
src/Core/Banshee.ThickClient/Makefile.am | 6 ++++++
4 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/build/m4/banshee/gconf.m4 b/build/m4/banshee/gconf.m4
index 16239db..fbf1ce6 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 c5c5675..c3891c1 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 0000000..d69fdc8
--- /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 5eeaff2..bdcea43 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]