[asterisk-commits] murf: branch murf/bug11210 r114038 - in /team/murf/bug11210: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 10 13:19:36 CDT 2008


Author: murf
Date: Thu Apr 10 13:19:36 2008
New Revision: 114038

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114038
Log:
Added ao2_object_get_lockaddr() to help debug object locking, in that you can use it to get lock addresses you can match against lock reports.

Modified:
    team/murf/bug11210/include/asterisk/astobj2.h
    team/murf/bug11210/main/astobj2.c

Modified: team/murf/bug11210/include/asterisk/astobj2.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/include/asterisk/astobj2.h?view=diff&rev=114038&r1=114037&r2=114038
==============================================================================
--- team/murf/bug11210/include/asterisk/astobj2.h (original)
+++ team/murf/bug11210/include/asterisk/astobj2.h Thu Apr 10 13:19:36 2008
@@ -467,6 +467,19 @@
  * \return 0 on success, other values on error.
  */
 int ao2_trylock(void *a);
+
+/*! \brief
+ * Return the lock address of an object
+ *
+ * \param a A pointer to the object we want.
+ * \return the address of the lock, else NULL.
+ * 
+ * This function comes in handy mainly for debugging locking 
+ * situations, where the locking trace code reports the 
+ * lock address, this allows you to correlate against
+ * object address, to match objects to reported locks.
+ */
+void *ao2_object_get_lockaddr(void *obj);
 
 /*! 
  \page AstObj2_Containers AstObj2 Containers

Modified: team/murf/bug11210/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/astobj2.c?view=diff&rev=114038&r1=114037&r2=114038
==============================================================================
--- team/murf/bug11210/main/astobj2.c (original)
+++ team/murf/bug11210/main/astobj2.c Thu Apr 10 13:19:36 2008
@@ -22,10 +22,6 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/_private.h"
-/* make ALL functions available so if any file needs to use
-   the refcount debug tracing, it will be available. Turn
-   it off you want to save a little space */
-#define  REF_DEBUG 1
 #include "asterisk/astobj2.h"
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
@@ -178,13 +174,22 @@
 	
 	if (p == NULL)
 		return -1;
-
 	ret =  ast_mutex_trylock(&p->priv_data.lock);
 #ifdef AO2_DEBUG
 	if (!ret)
 		ast_atomic_fetchadd_int(&ao2.total_locked, 1);
 #endif
 	return ret;
+}
+
+void *ao2_object_get_lockaddr(void *obj)
+{
+	struct astobj2 *p = INTERNAL_OBJ(obj);
+	
+	if (p == NULL)
+		return NULL;
+
+	return &p->priv_data.lock;
 }
 
 /*




More information about the asterisk-commits mailing list