From 1eae184450a585f10c8988613e0f7259e1d6066a Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Wed, 6 Sep 2006 22:00:07 +0000 Subject: * doc/TODO: - Remove pending call locking todo item - dbus_connection_open now holds hard ref. Remove todo item - do proper locking on _dbus_bus_check_connection_and_unref and handle DBUS_BUS_STARTER. Remove todo item - Warn on closing of a shared connection. Remove todo item * bus/bus.c, bus/connection.c, bus/dispatch.c, dbus/dbus-bus.c, dbus/dbus-connection.c: Use the dbus_connection_close_internal so we don't get the warning when closing shared connections * test/test-service.c, test/test-shell-service.c: Applications don't close shared connections themselves so we unref instead of close * test/test-utils.c (test_connection_shutdown): Close the connection * dbus/dbus-bus.c (_dbus_bus_check_connection_and_unref): Changed to _dbus_bus_check_connection_and_unref_unlocked since we only call this method on a locked connection. Make sure we call _dbus_connection_unref_unlocked instead of dbus_connection_unref also. Handle DBUS_BUS_STARTER correctly * dbus/dbus-connection.c (connection_record_shared_unlocked): Mark as shared and hard ref the connection (connection_forget_shared_unlocked): Remove the hard ref from the connection (_dbus_connection_close_internal_and_unlock): New internal function which takes a locked connection and unlocks it after closing it (_dbus_connection_close_internal): New internal function which acts like the origonal dbus_connection_close method by grabbing a connection lock and calling _dbus_connection_close_internal_and_unlock (dbus_connection_close): Public close method, warns when the app trys to close a shared connection --- dbus/dbus-bus.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'dbus/dbus-bus.c') diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index eae46051..fd58fab8 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -28,6 +28,7 @@ #include "dbus-message.h" #include "dbus-marshal-validate.h" #include "dbus-threads-internal.h" +#include "dbus-connection-internal.h" #include /** @@ -303,20 +304,29 @@ ensure_bus_data (DBusConnection *connection) } /* internal function that checks to see if this - is a shared bus connection and if it is unref it */ + is a shared connection owned by the bus and if it is unref it */ void -_dbus_bus_check_connection_and_unref (DBusConnection *connection) +_dbus_bus_check_connection_and_unref_unlocked (DBusConnection *connection) { + _DBUS_LOCK (bus); + if (bus_connections[DBUS_BUS_SYSTEM] == connection) { bus_connections[DBUS_BUS_SYSTEM] = NULL; - dbus_connection_unref (connection); + _dbus_connection_unref_unlocked (connection); } else if (bus_connections[DBUS_BUS_SESSION] == connection) { bus_connections[DBUS_BUS_SESSION] = NULL; - dbus_connection_unref (connection); + _dbus_connection_unref_unlocked (connection); } + else if (bus_connections[DBUS_BUS_STARTER] == connection) + { + bus_connections[DBUS_BUS_STARTER] = NULL; + _dbus_connection_unref_unlocked (connection); + } + + _DBUS_UNLOCK (bus); } static DBusConnection * @@ -394,7 +404,7 @@ internal_bus_get (DBusBusType type, if (!dbus_bus_register (connection, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); - dbus_connection_close (connection); + _dbus_connection_close_internal (connection); dbus_connection_unref (connection); _DBUS_UNLOCK (bus); -- cgit