ipconfig: add debugging to ref counting functions
authorJukka Rissanen <jukka.rissanen@nokia.com>
Wed, 5 Jan 2011 13:14:11 +0000 (15:14 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 6 Jan 2011 02:51:19 +0000 (18:51 -0800)
src/ipconfig.c

index 690b51e..b5dc98f 100644 (file)
@@ -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);