[asterisk-commits] rmudgett: trunk r342112 - /trunk/apps/app_queue.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Oct 24 16:02:01 CDT 2011
Author: rmudgett
Date: Mon Oct 24 16:01:58 2011
New Revision: 342112
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342112
Log:
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)
Modified:
trunk/apps/app_queue.c
Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=342112&r1=342111&r2=342112
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Mon Oct 24 16:01:58 2011
@@ -1678,19 +1678,26 @@
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;
}
/*!
More information about the asterisk-commits
mailing list