summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/asterisk/astobj2.h6
-rw-r--r--main/astobj2.c10
2 files changed, 14 insertions, 2 deletions
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index 21dc60611..ff35599ca 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -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),
};
/*!
diff --git a/main/astobj2.c b/main/astobj2.c
index 50886de2e..bdd70c63e 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -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) {