[asterisk-commits] dvossel: trunk r299135 - in /trunk: include/asterisk/astobj2.h main/astobj2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 20 18:03:13 UTC 2010


Author: dvossel
Date: Mon Dec 20 12:03:09 2010
New Revision: 299135

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=299135
Log:
New astobj2 flag for issuing a callback without locking the container.

Modified:
    trunk/include/asterisk/astobj2.h
    trunk/main/astobj2.c

Modified: trunk/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/astobj2.h?view=diff&rev=299135&r1=299134&r2=299135
==============================================================================
--- trunk/include/asterisk/astobj2.h (original)
+++ trunk/include/asterisk/astobj2.h Mon Dec 20 12:03:09 2010
@@ -674,6 +674,12 @@
 	 * the hash value on the argument.
 	 */
 	OBJ_CONTINUE     = (1 << 4),
+	/*! 
+	 * \brief By using this flag, the ao2_container being searched will _NOT_
+	 * be locked.  Only use this flag if the ao2_container is being protected
+	 * by another mechanism other that the internal ao2_lock.
+	 */
+	OBJ_NOLOCK     = (1 << 5),
 };
 
 /*!

Modified: trunk/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/astobj2.c?view=diff&rev=299135&r1=299134&r2=299135
==============================================================================
--- trunk/main/astobj2.c (original)
+++ trunk/main/astobj2.c Mon Dec 20 12:03:09 2010
@@ -654,7 +654,10 @@
 		last = i + 1;
 	}
 
-	ao2_lock(c);	/* avoid modifications to the content */
+
+	if (!(flags & OBJ_NOLOCK)) {
+		ao2_lock(c);	/* avoid modifications to the content */
+	}
 
 	for (; i < last ; i++) {
 		/* scan the list with prev-cur pointers */
@@ -738,7 +741,10 @@
 			last = start;
 		}
 	}
-	ao2_unlock(c);
+
+	if (!(flags & OBJ_NOLOCK)) {
+		ao2_unlock(c);
+	}
 
 	/* if multi_container was created, we are returning multiple objects */
 	if (multi_container != NULL) {




More information about the asterisk-commits mailing list