]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Wed Sep 3 13:55:22 EDT 2008 Pekka Pessi <first.last@nokia.com>
authorMichael Jerris <mike@jerris.com>
Wed, 3 Sep 2008 18:29:19 +0000 (18:29 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 3 Sep 2008 18:29:19 +0000 (18:29 +0000)
  * nua: using HAVE_MEMLEAK_LOG

  Logging nua_handle_ref() and nua_handle_unref().

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9420 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h

index 55bf715ebbf842c1d5496aaf62118d1214756f8e..5c67f4b6f22b3542cb09eef5815bdfe78704c917 100644 (file)
@@ -1 +1 @@
-Wed Sep  3 14:27:37 EDT 2008
+Wed Sep  3 14:29:03 EDT 2008
index df9643871fb4fa4d1c4bc11668a3bf7c700ff4cb..19e2655e0b0963a1471d43b5450b21b01d41d7c7 100644 (file)
@@ -163,8 +163,47 @@ static void nh_destructor(void *arg)
   SU_DEBUG_0(("nh_destructor(%p)\n", (void *)nh));
 }
 
-#undef nua_handle_ref
-#undef nua_handle_unref
+#if HAVE_MEMLEAK_LOG
+
+nua_handle_t *
+_nua_handle_ref_by(nua_handle_t *nh,
+                  char const *file, unsigned line,
+                  char const *function)
+{
+  if (nh)
+    SU_DEBUG_0(("%p - nua_handle_ref() => "MOD_ZU" by %s:%u: %s()\n",
+               nh, su_home_refcount((su_home_t *)nh) + 1, file, line, by));
+  return (nua_handle_t *)su_home_ref((su_home_t *)nh);
+}
+
+int
+_nua_handle_unref_by(nua_handle_t *nh,
+                   char const *file, unsigned line,
+                   char const *function)
+{
+  if (nh) {
+    size_t refcount = su_home_refcount((su_home_t *)nh) - 1;
+    int freed =  su_home_unref((su_home_t *)nh);
+    if (freed) refcount = 0;
+    SU_DEBUG_0(("%p - nua_handle_unref() => "MOD_ZU" by %s:%u: %s()\n",
+               nh, refcount, file, line, by));
+    return freed;
+  }
+
+  return 0;
+}
+
+nua_handle_t *nua_handle_ref(nua_handle_t *nh)
+{
+  return _nua_handle_ref_by(nh, "<app>", 0, "<app>")
+}
+
+int nua_handle_unref(nua_handle_t *nh)
+{
+  return _nua_handle_unref_by(nh, "<app>", 0, "<app>")
+}
+
+#else
 
 /** Make a new reference to handle.
  *
@@ -198,6 +237,8 @@ int nua_handle_unref(nua_handle_t *nh)
   return su_home_unref(nh->nh_home);
 }
 
+#endif
+
 /** Generate an instance identifier. */
 char const *nua_generate_instance_identifier(su_home_t *home)
 {
index d5144ca2db6b00ee51fbe8afce35685c1eec4783..81a01636095392a201053ca3ac9bbf1d1134bf36 100644 (file)
@@ -103,37 +103,6 @@ typedef struct register_usage nua_registration_t;
   TAG_IF((include) && (soa) && soa_is_remote_chat_active(soa) >= 0,    \
         SOATAG_ACTIVE_CHAT(soa_is_remote_chat_active(soa)))
 
-#if HAVE_NUA_HANDLE_DEBUG
-
-#define nua_handle_ref(nh) nua_handle_ref_by((nh), __func__)
-#define nua_handle_unref(nh) nua_handle_unref_by((nh), __func__)
-
-su_inline nua_handle_t *nua_handle_ref_by(nua_handle_t *nh,
-                                         char const *by)
-{
-  if (nh)
-    SU_DEBUG_0(("nua_handle_ref(%p) => "MOD_ZU" by %s\n", nh, 
-               su_home_refcount((su_home_t *)nh) + 1,
-               by));
-  return (nua_handle_t *)su_home_ref((su_home_t *)nh);
-}
-
-su_inline int nua_handle_unref_by(nua_handle_t *nh, char const *by)
-{
-  if (nh) {
-    size_t refcount = su_home_refcount((su_home_t *)nh) - 1;
-    int freed =  su_home_unref((su_home_t *)nh);
-    if (freed) refcount = 0;
-    SU_DEBUG_0(("nua_handle_unref(%p) => "MOD_ZU" by %s\n",
-               nh, refcount, by));
-    return freed;
-  }
-
-  return 0; 
-}
-
-#endif
-
 /** @internal @brief NUA handle. 
  *
  */
@@ -277,6 +246,20 @@ struct nua_s {
 #define __func__ "nua"
 #endif
 
+#if HAVE_MEMLEAK_LOG
+
+#define nua_handle_ref(nh) \
+  _nua_handle_ref_by((nh), __FILE__, __LINE__, __func__)
+#define nua_handle_unref(nh) \
+  _nua_handle_unref_by((nh), __FILE__, __LINE__, __func__)
+
+nua_handle_t *_nua_handle_ref_by(
+  nua_handle_t *nh, char const *file, unsigned line, char const *by);
+int _nua_handle_unref_by(
+  nua_handle_t *nh, char const *file, unsigned line, char const *by);
+
+#endif
+
 su_inline nua_t *nua_stack_ref(nua_t *nua)
 { 
   return (nua_t *)su_home_ref(nua->nua_home);