dect
/
asterisk
Archived
13
0
Fork 0

New astobj2 flag for issuing a callback without locking the container.

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@299135 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
dvossel 2010-12-20 18:03:09 +00:00
parent 27e3e630ca
commit 66e4685822
2 changed files with 14 additions and 2 deletions

View 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),
};
/*!

View 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) {