aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-29 17:48:07 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-29 17:48:07 +0000
commit3b47ea0232de5be7caced4d5d90765a01ffb1a79 (patch)
tree20b402418b2a00cbabb8c6dc02af9d26021dc5ea /funcs
parent12fd7ceadbebb44bc9347f9fb7c392335fa5b512 (diff)
Merged revisions 140489 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r140489 | mmichelson | 2008-08-29 12:47:17 -0500 (Fri, 29 Aug 2008) | 30 lines Merged revisions 140488 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r140488 | mmichelson | 2008-08-29 12:34:17 -0500 (Fri, 29 Aug 2008) | 22 lines After working on the ao2_containers branch, I noticed something a bit strange. In all cases where we provide a callback function to ao2_container_alloc, the callback function would only return 0 or CMP_MATCH. After inspecting the ao2_callback() code carefully, I found that if you're only looking for one specific item, then you should return CMP_MATCH | CMP_STOP. Otherwise, astobj2 will continue traversing the current bucket until the end searching for more matches. In cases like chan_iax2 where in 1.4, all the peers are shoved into a single bucket, this makes for potentially terrible performance since the entire bucket will be traversed even if the peer is one of the first ones come across in the bucket. All the changes I have made were for cases where the callback function defined was passed to ao2_container_alloc so that calls to ao2_find could find a unique instance of whatever object was being stored in the container. ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@140490 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_dialgroup.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/funcs/func_dialgroup.c b/funcs/func_dialgroup.c
index 6a9596e62..c3674beb9 100644
--- a/funcs/func_dialgroup.c
+++ b/funcs/func_dialgroup.c
@@ -67,9 +67,9 @@ static int group_cmp_fn(void *obj1, void *name2, int flags)
struct group *g1 = obj1, *g2 = name2;
char *name = name2;
if (flags & OBJ_POINTER)
- return strcmp(g1->name, g2->name) ? 0 : CMP_MATCH;
+ return strcmp(g1->name, g2->name) ? 0 : CMP_MATCH | CMP_STOP;
else
- return strcmp(g1->name, name) ? 0 : CMP_MATCH;
+ return strcmp(g1->name, name) ? 0 : CMP_MATCH | CMP_STOP;
}
static int entry_hash_fn(const void *obj, const int flags)
@@ -83,9 +83,9 @@ static int entry_cmp_fn(void *obj1, void *name2, int flags)
struct group_entry *e1 = obj1, *e2 = name2;
char *name = name2;
if (flags & OBJ_POINTER)
- return strcmp(e1->name, e2->name) ? 0 : CMP_MATCH;
+ return strcmp(e1->name, e2->name) ? 0 : CMP_MATCH | CMP_STOP;
else
- return strcmp(e1->name, name) ? 0 : CMP_MATCH;
+ return strcmp(e1->name, name) ? 0 : CMP_MATCH | CMP_STOP;
}
static int dialgroup_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)