]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
New astobj2 flag for issuing a callback without locking the container.
authorDavid Vossel <dvossel@digium.com>
Mon, 20 Dec 2010 18:03:09 +0000 (18:03 +0000)
committerDavid Vossel <dvossel@digium.com>
Mon, 20 Dec 2010 18:03:09 +0000 (18:03 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@299135 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/astobj2.h
main/astobj2.c

index 21dc60611b2b7eb92fdc75c7eb4dee183c475e67..ff35599caec85aa2ae513c6db7b5ae876601b49a 100644 (file)
@@ -674,6 +674,12 @@ enum search_flags {
         * 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),
 };
 
 /*!
index 50886de2ecbf09a0cd2ceee688268449c09ec1e2..bdd70c63e55bd1d0a078e70152c1d389749de6c4 100644 (file)
@@ -654,7 +654,10 @@ static void *internal_ao2_callback(struct ao2_container *c,
                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 @@ static void *internal_ao2_callback(struct ao2_container *c,
                        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) {