mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-26 14:27:14 +00:00
Changes applied from marta's team/marta/astobj2 branch to solve a race condition
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -501,6 +501,7 @@ void * ao2_iterator_next(struct ao2_iterator *a)
|
|||||||
{
|
{
|
||||||
int lim;
|
int lim;
|
||||||
struct bucket_list *p = NULL;
|
struct bucket_list *p = NULL;
|
||||||
|
void *ret = NULL;
|
||||||
|
|
||||||
if (INTERNAL_OBJ(a->c) == NULL)
|
if (INTERNAL_OBJ(a->c) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -541,14 +542,15 @@ found:
|
|||||||
a->version = p->version;
|
a->version = p->version;
|
||||||
a->obj = p;
|
a->obj = p;
|
||||||
a->c_version = a->c->version;
|
a->c_version = a->c->version;
|
||||||
|
ret = EXTERNAL_OBJ(p->astobj);
|
||||||
/* inc refcount of returned object */
|
/* inc refcount of returned object */
|
||||||
ao2_ref(EXTERNAL_OBJ(p->astobj), 1);
|
ao2_ref(ret, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a->flags & F_AO2I_DONTLOCK))
|
if (!(a->flags & F_AO2I_DONTLOCK))
|
||||||
ao2_unlock(a->c);
|
ao2_unlock(a->c);
|
||||||
|
|
||||||
return p ? EXTERNAL_OBJ(p->astobj) : NULL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* callback for destroying container.
|
/* callback for destroying container.
|
||||||
|
|||||||
Reference in New Issue
Block a user