summaryrefslogtreecommitdiff
path: root/dbus/dbus-pending-call.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-07-26 16:16:28 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-13 17:54:52 +0000
commit7ba7b9a931aa5a0959690f2512db7a7cd9f4b578 (patch)
tree2738cfae968cd8765e3d13459a2b6207ca0c4b30 /dbus/dbus-pending-call.c
parent926496567a238cee5364b8afe961274926706591 (diff)
downloaddbus-7ba7b9a931aa5a0959690f2512db7a7cd9f4b578.tar.gz
add and use _dbus_pending_call_trace_ref
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37286 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Lennart Poettering <lennart@poettering.net>
Diffstat (limited to 'dbus/dbus-pending-call.c')
-rw-r--r--dbus/dbus-pending-call.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c
index f9c94966..8a9d2f49 100644
--- a/dbus/dbus-pending-call.c
+++ b/dbus/dbus-pending-call.c
@@ -79,6 +79,27 @@ struct DBusPendingCall
unsigned int timeout_added : 1; /**< Have added the timeout */
};
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+static void
+_dbus_pending_call_trace_ref (DBusPendingCall *pending_call,
+ int old_refcount,
+ int new_refcount,
+ const char *why)
+{
+ static int enabled = -1;
+
+ _dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount,
+ new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled);
+}
+#else
+#define _dbus_pending_call_trace_ref(p, o, n, w) \
+ do \
+ {\
+ (void) (o); \
+ (void) (n); \
+ } while (0)
+#endif
+
static dbus_int32_t notify_user_data_slot = -1;
/**
@@ -140,7 +161,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;
}
@@ -377,7 +400,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;
}
@@ -440,6 +467,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);
@@ -554,9 +583,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;
}
@@ -570,13 +603,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);
}