From 0131fc0fb3928c2c50973d94768ff8bd0a70ac8b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 5 Jan 2011 15:14:11 +0200 Subject: [PATCH] ipconfig: add debugging to ref counting functions --- src/ipconfig.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ipconfig.c b/src/ipconfig.c index 690b51e..b5dc98f 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -915,6 +915,9 @@ struct connman_ipconfig *connman_ipconfig_create(int index, */ struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig) { + DBG("ipconfig %p refcount %d", ipconfig, + g_atomic_int_get(&ipconfig->refcount) + 1); + g_atomic_int_inc(&ipconfig->refcount); return ipconfig; @@ -928,8 +931,13 @@ struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig) */ void connman_ipconfig_unref(struct connman_ipconfig *ipconfig) { - if (ipconfig && - g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) { + if (ipconfig == NULL) + return; + + DBG("ipconfig %p refcount %d", ipconfig, + g_atomic_int_get(&ipconfig->refcount) - 1); + + if (g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) { __connman_ipconfig_disable(ipconfig); connman_ipconfig_set_ops(ipconfig, NULL); -- 2.7.4