X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-pending-call.c;h=be5341058ad9b1d3a45259bc074370b86bd0dfa4;hb=3ccb027c907f9ee2890028e83b60296204bbf478;hp=e7f5cd98b31927177c92d9b717ae07cc9f1d3a27;hpb=2a8be5a2f5d9c848e10c8c505f02eebd48276c3a;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index e7f5cd9..be53410 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -24,6 +24,7 @@ #include #include "dbus-internals.h" #include "dbus-connection-internal.h" +#include "dbus-message-internal.h" #include "dbus-pending-call-internal.h" #include "dbus-pending-call.h" #include "dbus-list.h" @@ -78,6 +79,20 @@ struct DBusPendingCall unsigned int timeout_added : 1; /**< Have added the timeout */ }; +static void +_dbus_pending_call_trace_ref (DBusPendingCall *pending_call, + int old_refcount, + int new_refcount, + const char *why) +{ +#ifdef DBUS_ENABLE_VERBOSE_MODE + static int enabled = -1; + + _dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount, + new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled); +#endif +} + static dbus_int32_t notify_user_data_slot = -1; /** @@ -139,7 +154,9 @@ _dbus_pending_call_new_unlocked (DBusConnection *connection, _dbus_connection_ref_unlocked (pending->connection); _dbus_data_slot_list_init (&pending->slot_list); - + + _dbus_pending_call_trace_ref (pending, 0, 1, "new_unlocked"); + return pending; } @@ -376,7 +393,11 @@ _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending, DBusPendingCall * _dbus_pending_call_ref_unlocked (DBusPendingCall *pending) { - _dbus_atomic_inc (&pending->refcount); + dbus_int32_t old_refcount; + + old_refcount = _dbus_atomic_inc (&pending->refcount); + _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1, + "ref_unlocked"); return pending; } @@ -439,6 +460,8 @@ _dbus_pending_call_unref_and_unlock (DBusPendingCall *pending) old_refcount = _dbus_atomic_dec (&pending->refcount); _dbus_assert (old_refcount > 0); + _dbus_pending_call_trace_ref (pending, old_refcount, + old_refcount - 1, "unref_and_unlock"); CONNECTION_UNLOCK (pending->connection); @@ -459,8 +482,8 @@ _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending) return pending->completed; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (pending_call_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots)); /** * Stores a pointer on a #DBusPendingCall, along @@ -553,9 +576,13 @@ _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending, DBusPendingCall * dbus_pending_call_ref (DBusPendingCall *pending) { + dbus_int32_t old_refcount; + _dbus_return_val_if_fail (pending != NULL, NULL); - _dbus_atomic_inc (&pending->refcount); + old_refcount = _dbus_atomic_inc (&pending->refcount); + _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1, + "ref"); return pending; } @@ -569,13 +596,15 @@ dbus_pending_call_ref (DBusPendingCall *pending) void dbus_pending_call_unref (DBusPendingCall *pending) { - dbus_bool_t last_unref; + dbus_int32_t old_refcount; _dbus_return_if_fail (pending != NULL); - last_unref = (_dbus_atomic_dec (&pending->refcount) == 1); + old_refcount = _dbus_atomic_dec (&pending->refcount); + _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount - 1, + "unref"); - if (last_unref) + if (old_refcount == 1) _dbus_pending_call_last_unref(pending); } @@ -595,6 +624,8 @@ dbus_pending_call_set_notify (DBusPendingCall *pending, void *user_data, DBusFreeFunction free_user_data) { + dbus_bool_t ret = FALSE; + _dbus_return_val_if_fail (pending != NULL, FALSE); CONNECTION_LOCK (pending->connection); @@ -602,13 +633,15 @@ dbus_pending_call_set_notify (DBusPendingCall *pending, /* could invoke application code! */ if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot, user_data, free_user_data)) - return FALSE; + goto out; pending->function = function; + ret = TRUE; +out: CONNECTION_UNLOCK (pending->connection); - return TRUE; + return ret; } /** @@ -680,7 +713,8 @@ dbus_pending_call_steal_reply (DBusPendingCall *pending) pending->reply = NULL; CONNECTION_UNLOCK (pending->connection); - + + _dbus_message_trace_ref (message, -1, -1, "dbus_pending_call_steal_reply"); return message; } @@ -727,7 +761,6 @@ dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p) _dbus_return_val_if_fail (slot_p != NULL, FALSE); return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (pending_call_slots), slot_p); }