diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-03 18:40:12 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-03 18:40:12 +0000 |
commit | 1ca6b25a00ea19b5553236e544801a85e69b4dbd (patch) | |
tree | 34ce1ee6c86c2c2c14e81f283b39f6718d3039e5 /main/astobj2.c | |
parent | 8fc2071f673612ef75a5cecb48e0bade7bd2c765 (diff) |
Merged revisions 215955 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r215955 | dvossel | 2009-09-03 11:31:54 -0500 (Thu, 03 Sep 2009) | 6 lines
Merge code associated with AST-2009-006
(closes issue #12912)
Reported by: rathaus
Tested by: tilghman, russell, dvossel, dbrooks
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@216003 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index 6b664ccbb..2d8aafad1 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -448,7 +448,7 @@ void *ao2_callback(struct ao2_container *c, const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg) { - int i, last; /* search boundaries */ + int i, start, last; /* search boundaries */ void *ret = NULL; if (INTERNAL_OBJ(c) == NULL) /* safety check on the argument */ @@ -469,13 +469,15 @@ void *ao2_callback(struct ao2_container *c, * (this only for the time being. We need to optimize this.) */ if ((flags & OBJ_POINTER)) /* we know hash can handle this case */ - i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets; + start = i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets; else /* don't know, let's scan all buckets */ i = -1; /* XXX this must be fixed later. */ /* determine the search boundaries: i..last-1 */ if (i < 0) { - i = 0; + start = i = 0; + last = c->n_buckets; + } else if ((flags & OBJ_CONTINUE)) { last = c->n_buckets; } else { last = i + 1; @@ -531,6 +533,17 @@ void *ao2_callback(struct ao2_container *c, } } AST_LIST_TRAVERSE_SAFE_END; + + if (ret) { + /* This assumes OBJ_MULTIPLE with !OBJ_NODATA is still not implemented */ + break; + } + + if (i == c->n_buckets - 1 && (flags & OBJ_POINTER) && (flags & OBJ_CONTINUE)) { + /* Move to the beginning to ensure we check every bucket */ + i = -1; + last = start; + } } ao2_unlock(c); return ret; |