diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-07 09:55:58 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-07 09:55:58 (GMT) |
commit | fb3e09c620b519eed57488cb229d42ebb793f387 (patch) | |
tree | b0cacd3010bbb103fd4833ab4f0b2ce9de43a5d1 /src/dbus | |
parent | ed9fb96a626c284cebd4fcd9a2e00f32e202099a (diff) | |
download | Qt-fb3e09c620b519eed57488cb229d42ebb793f387.zip Qt-fb3e09c620b519eed57488cb229d42ebb793f387.tar.gz Qt-fb3e09c620b519eed57488cb229d42ebb793f387.tar.bz2 |
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
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusthread.cpp | 32 |
1 files changed, 5 insertions, 27 deletions
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<DBusMutex *>(new QMutex(QMutex::NonRecursive)); -} - -#if 0 static DBusMutex* recursive_mutex_new() { return reinterpret_cast<DBusMutex *>(new QMutex(QMutex::Recursive)); } -#endif static void mutex_free(DBusMutex *mutex) { delete reinterpret_cast<QMutex *>(mutex); } -static dbus_bool_t mutex_lock(DBusMutex *mutex) +static void mutex_lock(DBusMutex *mutex) { reinterpret_cast<QMutex *>(mutex)->lock(); - return true; } -static dbus_bool_t mutex_unlock(DBusMutex *mutex) +static void mutex_unlock(DBusMutex *mutex) { reinterpret_cast<QMutex *>(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 }; |