aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-03 18:41:27 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-03 18:41:27 +0000
commit89a9d8d87b55daa81e47661297926cb51fd48c02 (patch)
treedcb75b1a338179b4ccb9ae74ef496983b3497925 /main
parent6db835bab14425528512d2f5e678bc498760af8a (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.1@216004 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/acl.c2
-rw-r--r--main/astobj2.c19
2 files changed, 17 insertions, 4 deletions
diff --git a/main/acl.c b/main/acl.c
index 7e9660d97..65be13046 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -220,7 +220,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 9d23bf0f0..d6dc8b2d3 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -591,7 +591,7 @@ static void *__ao2_callback(struct ao2_container *c,
const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg,
char *tag, char *file, int line, const char *funcname)
{
- int i, last; /* search boundaries */
+ int i, start, last; /* search boundaries */
void *ret = NULL;
if (INTERNAL_OBJ(c) == NULL) /* safety check on the argument */
@@ -612,13 +612,15 @@ static 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;
@@ -680,6 +682,17 @@ static 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;