summaryrefslogtreecommitdiff
path: root/dbus/dbus-server.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-04-16 15:39:54 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-06-17 16:53:51 +0100
commitc80c20af46c5f43dcbe672f2c6d8aec0e7f2bbd6 (patch)
treeb88990c3946b35408a7463a3e51296800bd8f389 /dbus/dbus-server.c
parent7e9ee6c82e42ffa3f6e4e69e077f72df6f4107db (diff)
downloaddbus-c80c20af46c5f43dcbe672f2c6d8aec0e7f2bbd6.tar.gz
Replace individual global-lock variables with an array of DBusRMutex *
This means we can use a much simpler code structure in data-slot allocators: instead of giving them a DBusRMutex ** at first-allocation, we can just give them an index into the array, which can be done statically. It doesn't make us any more thread-safe-by-default - the mutexes will only actually be used if threads were already initialized - but it's substantially better than nothing. These locks really do have to be recursive: for instance, internal_bus_get() calls dbus_bus_register() under the bus lock, and dbus_bus_register() can call _dbus_connection_close_possibly_shared(), which takes the bus lock. 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: Ralf Habacker <ralf.habacker@freenet.de> Reviewed-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'dbus/dbus-server.c')
-rw-r--r--dbus/dbus-server.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c
index b62c2b40..e0212662 100644
--- a/dbus/dbus-server.c
+++ b/dbus/dbus-server.c
@@ -1071,9 +1071,8 @@ dbus_server_set_auth_mechanisms (DBusServer *server,
return TRUE;
}
-
-static DBusDataSlotAllocator slot_allocator;
-_DBUS_DEFINE_GLOBAL_LOCK (server_slots);
+static DBusDataSlotAllocator slot_allocator =
+ _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (server_slots));
/**
* Allocates an integer ID to be used for storing application-specific
@@ -1093,7 +1092,6 @@ dbus_bool_t
dbus_server_allocate_data_slot (dbus_int32_t *slot_p)
{
return _dbus_data_slot_allocator_alloc (&slot_allocator,
- (DBusRMutex **)&_DBUS_LOCK_NAME (server_slots),
slot_p);
}