Make taking a global lock automatically initialize locking if needed
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 16 Apr 2013 15:28:44 +0000 (16:28 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 17 Jun 2013 16:00:00 +0000 (17:00 +0100)
commit2b3272c75ae48c93911bd6f656965cf77d6de3e8
treec612839ca6bf80883028d7e39c7c894d8c56b900
parentc80c20af46c5f43dcbe672f2c6d8aec0e7f2bbd6
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>
14 files changed:
bus/stats.c
dbus/dbus-bus.c
dbus/dbus-connection.c
dbus/dbus-dataslot.c
dbus/dbus-internals.c
dbus/dbus-internals.h
dbus/dbus-list.c
dbus/dbus-memory.c
dbus/dbus-message.c
dbus/dbus-threads.c
dbus/dbus-userdb-util.c
dbus/dbus-userdb.c
dbus/dbus-userdb.h
test/name-test/test-threads-init.c