[asterisk-commits] rmudgett: branch 11 r388700 - in /branches/11: include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 14 13:55:59 CDT 2013


Author: rmudgett
Date: Tue May 14 13:55:57 2013
New Revision: 388700

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388700
Log:
Make ao2 global objects not always use the debug version of the ao2_ref() calls.

The debug versions of ao2_ref() should only be used if REF_DEBUG is
enabled so nothing is written to /tmp/refs unexpectedly.

(closes issue ASTERISK-21785)
Reported by: abelbeck
Patches:
      jira_asterisk_21785_v11.patch (license #5621) patch uploaded by rmudgett
Tested by: abelbeck

Modified:
    branches/11/include/asterisk/astobj2.h
    branches/11/main/astobj2.c

Modified: branches/11/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/astobj2.h?view=diff&rev=388700&r1=388699&r2=388700
==============================================================================
--- branches/11/include/asterisk/astobj2.h (original)
+++ branches/11/include/asterisk/astobj2.h Tue May 14 13:55:57 2013
@@ -625,11 +625,20 @@
  *
  * \return Nothing
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_release(holder, tag)	\
 	__ao2_global_obj_release(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_release(holder)	\
 	__ao2_global_obj_release(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
+#else
+
+#define ao2_t_global_obj_release(holder, tag)	\
+	__ao2_global_obj_release(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_release(holder)	\
+	__ao2_global_obj_release(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name);
 
 /*!
@@ -647,11 +656,20 @@
  * \retval Reference to previous global ao2 object stored.
  * \retval NULL if no object available.
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_replace(holder, obj, tag)	\
 	__ao2_global_obj_replace(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_replace(holder, obj)	\
 	__ao2_global_obj_replace(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
+#else
+
+#define ao2_t_global_obj_replace(holder, obj, tag)	\
+	__ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_replace(holder, obj)	\
+	__ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name);
 
 /*!
@@ -670,10 +688,20 @@
  * \retval 0 The global object was previously empty
  * \retval 1 The global object was not previously empty
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_replace_unref(holder, obj, tag)	\
 	__ao2_global_obj_replace_unref(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_replace_unref(holder, obj)	\
 	__ao2_global_obj_replace_unref(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+
+#else
+
+#define ao2_t_global_obj_replace_unref(holder, obj, tag)	\
+	__ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_replace_unref(holder, obj)	\
+	__ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name);
 
 /*!
@@ -686,10 +714,19 @@
  * \retval Reference to current ao2 object stored in the holder.
  * \retval NULL if no object available.
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_ref(holder, tag)	\
 	__ao2_global_obj_ref(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_ref(holder)	\
 	__ao2_global_obj_ref(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+
+#else
+
+#define ao2_t_global_obj_ref(holder, tag)	\
+	__ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_ref(holder)	\
+	__ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
 
 void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name);
 

Modified: branches/11/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/astobj2.c?view=diff&rev=388700&r1=388699&r2=388700
==============================================================================
--- branches/11/main/astobj2.c (original)
+++ branches/11/main/astobj2.c Tue May 14 13:55:57 2013
@@ -656,7 +656,11 @@
 
 	/* Release the held ao2 object. */
 	if (holder->obj) {
-		__ao2_ref_debug(holder->obj, -1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(holder->obj, -1, tag, file, line, func);
+		} else {
+			__ao2_ref(holder->obj, -1);
+		}
 		holder->obj = NULL;
 	}
 
@@ -678,7 +682,11 @@
 	}
 
 	if (obj) {
-		__ao2_ref_debug(obj, +1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(obj, +1, tag, file, line, func);
+		} else {
+			__ao2_ref(obj, +1);
+		}
 	}
 	obj_old = holder->obj;
 	holder->obj = obj;
@@ -694,7 +702,11 @@
 
 	obj_old = __ao2_global_obj_replace(holder, obj, tag, file, line, func, name);
 	if (obj_old) {
-		__ao2_ref_debug(obj_old, -1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(obj_old, -1, tag, file, line, func);
+		} else {
+			__ao2_ref(obj_old, -1);
+		}
 		return 1;
 	}
 	return 0;
@@ -717,7 +729,11 @@
 
 	obj = holder->obj;
 	if (obj) {
-		__ao2_ref_debug(obj, +1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(obj, +1, tag, file, line, func);
+		} else {
+			__ao2_ref(obj, +1);
+		}
 	}
 
 	__ast_rwlock_unlock(file, line, func, &holder->lock, name);




More information about the asterisk-commits mailing list