X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fdbus.git;a=blobdiff_plain;f=dbus%2Fdbus-connection.c;h=4923812ed5bec44b3998fffed620d4ff1971a3c5;hp=21d0db98e76f6a8dc0adf690e26e86aa9d80e689;hb=bd6d8d261df61ed8b396434e5a80285d43184d6c;hpb=2e2938fcf4e5bc09d8ef24a681fe69d927432088 diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 21d0db9..4923812 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2702,12 +2702,8 @@ free_outgoing_message (void *element, dbus_message_unref (message); } -/* This is run without the mutex held, but after the last reference - * to the connection has been dropped we should have no thread-related - * problems - */ static void -_dbus_connection_last_unref (DBusConnection *connection) +_dbus_connection_last_unref_internal (DBusConnection *connection, dbus_bool_t unref_transport) { DBusList *link; @@ -2762,17 +2758,18 @@ _dbus_connection_last_unref (DBusConnection *connection) _dbus_list_foreach (&connection->outgoing_messages, free_outgoing_message, - connection); + connection); _dbus_list_clear (&connection->outgoing_messages); _dbus_list_foreach (&connection->incoming_messages, - (DBusForeachFunction) dbus_message_unref, - NULL); + (DBusForeachFunction) dbus_message_unref, + NULL); _dbus_list_clear (&connection->incoming_messages); _dbus_counter_unref (connection->outgoing_counter); - _dbus_transport_unref (connection->transport); + if(unref_transport) + _dbus_transport_unref (connection->transport); if (connection->disconnect_message_link) { @@ -2794,6 +2791,16 @@ _dbus_connection_last_unref (DBusConnection *connection) dbus_free (connection); } +/* This is run without the mutex held, but after the last reference + * to the connection has been dropped we should have no thread-related + * problems + */ +static void +_dbus_connection_last_unref (DBusConnection *connection) +{ + _dbus_connection_last_unref_internal(connection, TRUE); +} + /** * Decrements the reference count of a DBusConnection, and finalizes * it if the count reaches zero. @@ -2842,6 +2849,22 @@ dbus_connection_unref (DBusConnection *connection) } } +void +dbus_connection_unref_phantom (DBusConnection *connection) +{ + dbus_int32_t old_refcount; + + _dbus_return_if_fail (connection != NULL); + _dbus_return_if_fail (connection->generation == _dbus_current_generation); + + old_refcount = _dbus_atomic_dec (&connection->refcount); + + _dbus_connection_trace_ref (connection, old_refcount, old_refcount - 1, "unref"); + + if (old_refcount == 1) + _dbus_connection_last_unref_internal(connection, FALSE); +} + /* * Note that the transport can disconnect itself (other end drops us) * and in that case this function never runs. So this function must