From 7cee956b4875dfd28c85dd2b6d8570eda7fdb1df Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Sep 2014 13:32:45 +0100 Subject: [PATCH 1/2] Require a modern libdbus and a modern GLib This means we can assume that GLib and libdbus are thread-safe by default. Also explicitly document that the object-mapping layer of dbus-glib is not thread-safe. --- configure.ac | 7 ++----- dbus/dbus-gthread.c | 9 ++++++--- test/core/Makefile.am | 6 ------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 7891ce6..999e00f 100644 --- a/configure.ac +++ b/configure.ac @@ -259,15 +259,12 @@ XML_CFLAGS= #### Set up final flags -PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.2.16]) +PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.8]) AC_SUBST([DBUS_CFLAGS]) AC_SUBST([DBUS_LIBS]) # Glib detection -PKG_CHECK_MODULES([DBUS_GLIB], [gobject-2.0 >= 2.26, gio-2.0 >= 2.26]) -PKG_CHECK_MODULES(DBUS_GLIB_THREADS, gthread-2.0 >= 2.6, have_glib_threads=yes, have_glib_threads=no) - -AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes) +PKG_CHECK_MODULES([DBUS_GLIB], [gobject-2.0 >= 2.32, gio-2.0 >= 2.32, gthread-2.0 >= 2.32]) GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` AC_SUBST(GLIB_GENMARSHAL) diff --git a/dbus/dbus-gthread.c b/dbus/dbus-gthread.c index 5d937b3..a88141b 100644 --- a/dbus/dbus-gthread.c +++ b/dbus/dbus-gthread.c @@ -37,14 +37,17 @@ * once and must be called prior to calling any * other function in the D-BUS API. * + * Equivalent to dbus_threads_init_default(), which does nothing. + * dbus-glib requires dbus >= 1.8, which is thread-safe by default. + * + * Note that dbus-glib's GObject mapping is explicitly *not* thread-safe. + * * Deprecated: New code should use GDBus instead. GDBus is always * thread-safe, whereas dbus-glib is never thread-safe. */ void dbus_g_thread_init (void) { - if (!g_thread_supported ()) - g_error ("g_thread_init() must be called before dbus_threads_init()"); - + /* keep this pointless method call just in case */ dbus_threads_init_default (); } diff --git a/test/core/Makefile.am b/test/core/Makefile.am index e4bceb4..2d66355 100644 --- a/test/core/Makefile.am +++ b/test/core/Makefile.am @@ -50,7 +50,6 @@ EXTRA_DIST=run-test.sh run-peer-test.sh test-service-glib.xml my-object-marshal. if DBUS_BUILD_TESTS -if HAVE_GLIB_THREADS THREAD_APPS=test-thread-server test-thread-client test-profile test_thread_server_SOURCES= \ @@ -60,7 +59,6 @@ test_thread_server_SOURCES= \ test_thread_client_SOURCES= \ test-thread-client.c \ test-thread.h -endif ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we ## build even when not doing "make check" @@ -183,13 +181,9 @@ CLEANFILES = \ else ### not building tests -if HAVE_GLIB_THREADS noinst_PROGRAMS=test-profile -endif endif -if HAVE_GLIB_THREADS test_profile_SOURCES= \ test-profile.c -endif -- 2.1.0