summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2008-08-29 17:47:17 +0000
committerMark Michelson <mmichelson@digium.com>2008-08-29 17:47:17 +0000
commit5dfefa5ee6e6a836f61a27d1d9348ff8564fba89 (patch)
tree60afe0702c0b3d5e4620a3f0fe944af1b9852f67 /main
parenta4e8af9af20365b3ac5c3da76976b7bdcc4719d4 (diff)
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: https://origsvn.digium.com/svn/asterisk/trunk@140489 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/config.c2
-rw-r--r--main/features.c2
-rw-r--r--main/manager.c2
-rw-r--r--main/taskprocessor.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/main/config.c b/main/config.c
index 73f3865f8..40b116a47 100644
--- a/main/config.c
+++ b/main/config.c
@@ -170,7 +170,7 @@ static int hash_string(const void *obj, const int flags)
static int hashtab_compare_strings(void *a, void *b, int flags)
{
const struct inclfile *ae = a, *be = b;
- return !strcmp(ae->fname, be->fname) ? CMP_MATCH : 0;
+ return !strcmp(ae->fname, be->fname) ? CMP_MATCH | CMP_STOP : 0;
}
static struct ast_config_map {
diff --git a/main/features.c b/main/features.c
index dd56f9bd3..9d228acc2 100644
--- a/main/features.c
+++ b/main/features.c
@@ -230,7 +230,7 @@ static int parkinglot_hash_cb(const void *obj, const int flags)
static int parkinglot_cmp_cb(void *obj, void *arg, int flags)
{
struct ast_parkinglot *parkinglot = obj, *parkinglot2 = arg;
- return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH : 0;
+ return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH | CMP_STOP : 0;
}
/*!
diff --git a/main/manager.c b/main/manager.c
index 6d2c47f26..4aa1be631 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3566,7 +3566,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;
}
/*! \brief Convert the input into XML or HTML.
diff --git a/main/taskprocessor.c b/main/taskprocessor.c
index d98d97f1c..450d579c1 100644
--- a/main/taskprocessor.c
+++ b/main/taskprocessor.c
@@ -339,7 +339,7 @@ static int tps_cmp_cb(void *obj, void *arg, int flags)
{
struct ast_taskprocessor *lhs = obj, *rhs = arg;
- return !strcasecmp(lhs->name, rhs->name) ? CMP_MATCH : 0;
+ return !strcasecmp(lhs->name, rhs->name) ? CMP_MATCH | CMP_STOP : 0;
}
/* destroy the taskprocessor */