diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-01-20 12:01:45 +0200 |
---|---|---|
committer | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-01-24 11:48:06 +0100 |
commit | 79a38d9428030028696abe2ed8c30e3f6b7c4504 (patch) | |
tree | 9de63a204f2d43b9eeb6150c9efe8c90e6ca0c0f | |
parent | fd72bf69c08a873456b64f018ab2770cda8e2279 (diff) | |
download | connman-79a38d9428030028696abe2ed8c30e3f6b7c4504.tar.gz connman-79a38d9428030028696abe2ed8c30e3f6b7c4504.tar.bz2 connman-79a38d9428030028696abe2ed8c30e3f6b7c4504.zip |
service: Add caller information to ref/unref debug prints.
This helps to pin point the exact line/function who is taking the reference.
-rw-r--r-- | include/service.h | 14 | ||||
-rw-r--r-- | src/service.c | 13 |
2 files changed, 21 insertions, 6 deletions
diff --git a/include/service.h b/include/service.h index 36c86584..afa51a2c 100644 --- a/include/service.h +++ b/include/service.h @@ -89,8 +89,18 @@ enum connman_service_proxy_method { struct connman_service; struct connman_service *connman_service_create(void); -struct connman_service *connman_service_ref(struct connman_service *service); -void connman_service_unref(struct connman_service *service); + +#define connman_service_ref(service) \ + connman_service_ref_debug(service, __FILE__, __LINE__, __func__) + +#define connman_service_unref(service) \ + connman_service_unref_debug(service, __FILE__, __LINE__, __func__) + +struct connman_service * +connman_service_ref_debug(struct connman_service *service, + const char *file, int line, const char *caller); +void connman_service_unref_debug(struct connman_service *service, + const char *file, int line, const char *caller); enum connman_service_type connman_service_get_type(struct connman_service *service); char *connman_service_get_interface(struct connman_service *service); diff --git a/src/service.c b/src/service.c index b8906a6e..edf7b221 100644 --- a/src/service.c +++ b/src/service.c @@ -3532,9 +3532,12 @@ struct connman_service *connman_service_create(void) * * Increase reference counter of service */ -struct connman_service *connman_service_ref(struct connman_service *service) +struct connman_service * +connman_service_ref_debug(struct connman_service *service, + const char *file, int line, const char *caller) { - DBG("%p ref %d", service, service->refcount + 1); + DBG("%p ref %d by %s:%d:%s()", service, service->refcount + 1, + file, line, caller); __sync_fetch_and_add(&service->refcount, 1); @@ -3548,11 +3551,13 @@ struct connman_service *connman_service_ref(struct connman_service *service) * Decrease reference counter of service and release service if no * longer needed. */ -void connman_service_unref(struct connman_service *service) +void connman_service_unref_debug(struct connman_service *service, + const char *file, int line, const char *caller) { GSequenceIter *iter; - DBG("service %p ref %d", service, service->refcount - 1); + DBG("%p ref %d by %s:%d:%s()", service, service->refcount - 1, + file, line, caller); if (__sync_fetch_and_sub(&service->refcount, 1) != 1) return; |