From 3e9f1ee3e0dbe56596d3a97ff346a9b84e3501dc Mon Sep 17 00:00:00 2001 From: Richard Mudgett <rmudgett@digium.com> Date: Mon, 24 Oct 2011 21:01:58 +0000 Subject: [PATCH] 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 --- apps/app_queue.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/app_queue.c b/apps/app_queue.c index d3a53167ff..440702599f 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; } /*! -- GitLab