diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-10 16:19:45 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-10 16:19:45 +0000 |
commit | cd0865e4530da31064b84c1f1076c0addbdcf08a (patch) | |
tree | 0e3b90e4264e67cb50b8ca6d42bd2714a08d3158 /main/astobj2.c | |
parent | 992c26d7762b9100d52a714673f2ee2ef578d350 (diff) |
Changes applied from marta's team/marta/astobj2 branch to solve a race condition
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82124 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index cc357f176..5050d8c2c 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -501,6 +501,7 @@ void * ao2_iterator_next(struct ao2_iterator *a) { int lim; struct bucket_list *p = NULL; + void *ret = NULL; if (INTERNAL_OBJ(a->c) == NULL) return NULL; @@ -541,14 +542,15 @@ found: a->version = p->version; a->obj = p; a->c_version = a->c->version; + ret = EXTERNAL_OBJ(p->astobj); /* inc refcount of returned object */ - ao2_ref(EXTERNAL_OBJ(p->astobj), 1); + ao2_ref(ret, 1); } if (!(a->flags & F_AO2I_DONTLOCK)) ao2_unlock(a->c); - return p ? EXTERNAL_OBJ(p->astobj) : NULL; + return ret; } /* callback for destroying container. |