diff options
author | David Vossel <dvossel@digium.com> | 2009-09-03 16:31:54 +0000 |
---|---|---|
committer | David Vossel <dvossel@digium.com> | 2009-09-03 16:31:54 +0000 |
commit | d09f9fd00a08c9e143ea68003ecf87dfe970a8a9 (patch) | |
tree | c83c86ded8f9d5a32fd96c2ee708c8185407971d /main | |
parent | 6d6ce303cbf2dbcacd4a84f4f6613a66fae56c48 (diff) |
Merge code associated with AST-2009-006
(closes issue #12912)
Reported by: rathaus
Tested by: tilghman, russell, dvossel, dbrooks
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@215955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/acl.c | 2 | ||||
-rw-r--r-- | main/astobj2.c | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/main/acl.c b/main/acl.c index fea76a62b..8daeb4a84 100644 --- a/main/acl.c +++ b/main/acl.c @@ -225,7 +225,7 @@ void ast_free_ha(struct ast_ha *ha) } /* Copy HA structure */ -static void ast_copy_ha(struct ast_ha *from, struct ast_ha *to) +void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to) { memcpy(&to->netaddr, &from->netaddr, sizeof(from->netaddr)); memcpy(&to->netmask, &from->netmask, sizeof(from->netmask)); diff --git a/main/astobj2.c b/main/astobj2.c index 91ec1428c..9c99b29da 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -605,7 +605,7 @@ static void *internal_ao2_callback(struct ao2_container *c, const enum search_flags flags, void *cb_fn, void *arg, void *data, enum ao2_callback_type type, char *tag, char *file, int line, const char *funcname) { - int i, last; /* search boundaries */ + int i, start, last; /* search boundaries */ void *ret = NULL; ao2_callback_fn *cb_default = NULL; ao2_callback_data_fn *cb_withdata = NULL; @@ -642,13 +642,15 @@ static void *internal_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; @@ -716,6 +718,17 @@ static void *internal_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; |