diff options
author | Richard Mudgett <rmudgett@digium.com> | 2011-10-24 21:01:58 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2011-10-24 21:01:58 +0000 |
commit | 3e9f1ee3e0dbe56596d3a97ff346a9b84e3501dc (patch) | |
tree | 77be2b4ff18984ace244028488e8fc6b9985aa18 /apps | |
parent | 05c6628c55683e7ded7c28bd9ce8c0a20d580f98 (diff) |
Fix use of OBJ_KEY in Queue application.
To use the new OBJ_KEY flag, the container hash and compare callback
functions must be updated to support OBJ_KEY. Otherwise, bad things
happen.
(issue ASTERISK-14769)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@342112 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_queue.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c index d3a53167f..440702599 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1678,19 +1678,26 @@ static int compress_char(const char c) static int member_hash_fn(const void *obj, const int flags) { const struct member *mem = obj; - const char *chname = strchr(mem->interface, '/'); + const char *interface = (flags & OBJ_KEY) ? obj : mem->interface; + const char *chname = strchr(interface, '/'); int ret = 0, i; - if (!chname) - chname = mem->interface; - for (i = 0; i < 5 && chname[i]; i++) + + if (!chname) { + chname = interface; + } + for (i = 0; i < 5 && chname[i]; i++) { ret += compress_char(chname[i]) << (i * 6); + } return ret; } static int member_cmp_fn(void *obj1, void *obj2, int flags) { - struct member *mem1 = obj1, *mem2 = obj2; - return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP; + struct member *mem1 = obj1; + struct member *mem2 = obj2; + const char *interface = (flags & OBJ_KEY) ? obj2 : mem2->interface; + + return strcasecmp(mem1->interface, interface) ? 0 : CMP_MATCH | CMP_STOP; } /*! |