diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-08-29 17:34:17 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-08-29 17:34:17 +0000 |
commit | 513913ed734a565b7d7ad5de12a5b31d16042676 (patch) | |
tree | 67db9d7d59c943e64abd4a7b4cf5eff2833f9638 /main/manager.c | |
parent | 8e58cbf8a98692c44441f53f85b83311c267a1cb (diff) |
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.4@140488 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c index c1937ee27..8b10712e8 100644 --- a/main/manager.c +++ b/main/manager.c @@ -318,7 +318,7 @@ static int variable_count_cmp_fn(void *obj, void *vstr, int flags) * the address of both the struct and the string are exactly the same. */ struct variable_count *vc = obj; char *str = vstr; - return !strcmp(vc->varname, str) ? CMP_MATCH : 0; + return !strcmp(vc->varname, str) ? CMP_MATCH | CMP_STOP : 0; } static char *xml_translate(char *in, struct ast_variable *vars) |