From fb3e09c620b519eed57488cb229d42ebb793f387 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 7 Oct 2009 11:55:58 +0200 Subject: Use the recursive mutex functions for D-Bus only. At least in D-Bus 1.2.16, there's a deadlock caused by locking an already-locked mutex. When Qt is linked to libdbus-1 instead of dynamically loading it, it maintains legacy compatibility by only providing the non-recursive mutexes, which triggers this deadlock. The recursive functions have been present since 0.93, so I guess the non-recursive variants aren't tested. Report: https://bugzilla.novell.com/show_bug.cgi?id=482749#c30 --- configure | 2 +- dist/changes-4.6.0 | 5 ++++- src/dbus/qdbusthread.cpp | 32 +++++--------------------------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/configure b/configure index ea50b37..1a7a8ef 100755 --- a/configure +++ b/configure @@ -617,7 +617,7 @@ fi unset QTDIR # the minimum version of libdbus-1 that we require: -MIN_DBUS_1_VERSION=0.62 +MIN_DBUS_1_VERSION=0.93 # initalize internal variables CFG_CONFIGURE_EXIT_ON_ERROR=yes diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 2e7e699..cd9f130 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -19,6 +19,9 @@ information about a particular change. * General * **************************************************************************** + - QtDBus + * The minimum required version of the D-Bus reference library is + now 0.93. **************************************************************************** @@ -133,4 +136,4 @@ information about a particular change. for all floating point numbers, and this can be changed using the new function setFloatingPointPrecision(). Set Qt_4_5 as the version of the QDataStream to get the behavior of previous versions. - \ No newline at end of file + diff --git a/src/dbus/qdbusthread.cpp b/src/dbus/qdbusthread.cpp index 6e180b1..7bc107a 100644 --- a/src/dbus/qdbusthread.cpp +++ b/src/dbus/qdbusthread.cpp @@ -47,33 +47,24 @@ QT_USE_NAMESPACE -static DBusMutex* mutex_new() -{ - return reinterpret_cast(new QMutex(QMutex::NonRecursive)); -} - -#if 0 static DBusMutex* recursive_mutex_new() { return reinterpret_cast(new QMutex(QMutex::Recursive)); } -#endif static void mutex_free(DBusMutex *mutex) { delete reinterpret_cast(mutex); } -static dbus_bool_t mutex_lock(DBusMutex *mutex) +static void mutex_lock(DBusMutex *mutex) { reinterpret_cast(mutex)->lock(); - return true; } -static dbus_bool_t mutex_unlock(DBusMutex *mutex) +static void mutex_unlock(DBusMutex *mutex) { reinterpret_cast(mutex)->unlock(); - return true; } static DBusCondVar* condvar_new() @@ -110,42 +101,29 @@ QT_BEGIN_NAMESPACE bool qDBusInitThreads() { - // ### Disable the recursive mutex functions. + // Use only the non-recursive mutex functions static DBusThreadFunctions fcn = { - DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK | DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK | DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK | DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK | DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK | DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK, -#if 0 + DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK | DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK | DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK | DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK | DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK, -#endif - mutex_new, - mutex_free, - mutex_lock, - mutex_unlock, + 0, 0, 0, 0, // non-recursive mutex functions condvar_new, condvar_free, condvar_wait, condvar_wait_timeout, condvar_wake_one, condvar_wake_all, -#if 0 recursive_mutex_new, mutex_free, mutex_lock, mutex_unlock, -#else - 0, 0, 0, 0, -#endif 0, 0, 0, 0 }; -- cgit v0.12