network: Add caller information to ref/unref debug prints.
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 20 Jan 2012 10:01:49 +0000 (12:01 +0200)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 24 Jan 2012 10:48:07 +0000 (11:48 +0100)
include/network.h
src/network.c

index bb61f2d..91154c8 100644 (file)
@@ -64,8 +64,18 @@ struct connman_network;
 
 struct connman_network *connman_network_create(const char *identifier,
                                        enum connman_network_type type);
-struct connman_network *connman_network_ref(struct connman_network *network);
-void connman_network_unref(struct connman_network *network);
+
+#define connman_network_ref(network) \
+       connman_network_ref_debug(network, __FILE__, __LINE__, __func__)
+
+#define connman_network_unref(network) \
+       connman_network_unref_debug(network, __FILE__, __LINE__, __func__)
+
+struct connman_network *
+connman_network_ref_debug(struct connman_network *network,
+                       const char *file, int line, const char *caller);
+void connman_network_unref_debug(struct connman_network *network,
+                       const char *file, int line, const char *caller);
 
 enum connman_network_type connman_network_get_type(struct connman_network *network);
 const char *connman_network_get_identifier(struct connman_network *network);
index 45995e8..4664ea5 100644 (file)
@@ -387,10 +387,12 @@ struct connman_network *connman_network_create(const char *identifier,
  *
  * Increase reference counter of  network
  */
-struct connman_network *connman_network_ref(struct connman_network *network)
+struct connman_network *
+connman_network_ref_debug(struct connman_network *network,
+                       const char *file, int line, const char *caller)
 {
-       DBG("network %p name %s refcount %d", network, network->name,
-               network->refcount + 1);
+       DBG("%p name %s ref %d by %s:%d:%s()", network, network->name,
+               network->refcount + 1, file, line, caller);
 
        __sync_fetch_and_add(&network->refcount, 1);
 
@@ -403,10 +405,11 @@ struct connman_network *connman_network_ref(struct connman_network *network)
  *
  * Decrease reference counter of network
  */
-void connman_network_unref(struct connman_network *network)
+void connman_network_unref_debug(struct connman_network *network,
+                               const char *file, int line, const char *caller)
 {
-       DBG("network %p name %s refcount %d", network, network->name,
-               network->refcount - 1);
+       DBG("%p name %s ref %d by %s:%d:%s()", network, network->name,
+               network->refcount - 1, file, line, caller);
 
        if (__sync_fetch_and_sub(&network->refcount, 1) != 1)
                return;