summaryrefslogtreecommitdiff
path: root/test/name-test
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-04-16 16:28:44 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-06-17 17:00:00 +0100
commit2b3272c75ae48c93911bd6f656965cf77d6de3e8 (patch)
treec612839ca6bf80883028d7e39c7c894d8c56b900 /test/name-test
parentc80c20af46c5f43dcbe672f2c6d8aec0e7f2bbd6 (diff)
downloaddbus-2b3272c75ae48c93911bd6f656965cf77d6de3e8.tar.gz
Make taking a global lock automatically initialize locking if needed
This lets them be thread-safe by default, at the cost that they can now fail. init_uninitialized_locks() and init_global_locks() must now both reimplement the equivalent of _dbus_register_shutdown_func(), by using _dbus_platform_rmutex_lock() on the same underlying mutex around a call to _dbus_register_shutdown_func_unlocked(). This is because if they used the usual _DBUS_LOCK() API (as _dbus_register_shutdown_func() does), it would automatically try to initialize global locking, leading to infinite recursion. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk> Reviewed-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'test/name-test')
-rw-r--r--test/name-test/test-threads-init.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/name-test/test-threads-init.c b/test/name-test/test-threads-init.c
index 5e22852a..580ffe14 100644
--- a/test/name-test/test-threads-init.c
+++ b/test/name-test/test-threads-init.c
@@ -149,11 +149,15 @@ main (int argc, char *argv[])
&dispatch_cond1,
&io_path_cond1);
- check_mutex_lock (mutex1, mutex2, FALSE);
- check_mutex_lock (dispatch_mutex1, dispatch_mutex2, FALSE);
- check_mutex_lock (io_path_mutex1, io_path_mutex2, FALSE);
- check_condvar_lock (dispatch_cond1, dispatch_cond2, FALSE);
- check_condvar_lock (io_path_cond1, io_path_cond2, FALSE);
+ /* Since 1.7 it is no longer the case that mutex1 != mutex2, because
+ * initializing global locks automatically initializes locks
+ * in general. However, it is true that the mutex is not the dummy
+ * implementation, which is what we really wanted to check here. */
+ _dbus_assert (mutex1 != (DBusMutex *) 0xABCDEF);
+ _dbus_assert (dispatch_mutex1 != (DBusMutex *) 0xABCDEF);
+ _dbus_assert (dispatch_cond1 != (DBusCondVar *) 0xABCDEF2);
+ _dbus_assert (io_path_mutex1 != (DBusMutex *) 0xABCDEF);
+ _dbus_assert (io_path_cond1 != (DBusCondVar *) 0xABCDEF2);
_run_iteration (conn);
_dbus_connection_test_get_locks (conn, &mutex2,