[Asterisk-code-review] pjsip distributor.c: Fix unidentified requests hash functions. (asterisk[14])
Richard Mudgett
asteriskteam at digium.com
Fri Jun 30 12:01:08 CDT 2017
Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/5943
Change subject: pjsip_distributor.c: Fix unidentified_requests hash functions.
......................................................................
pjsip_distributor.c: Fix unidentified_requests hash functions.
The OBJ_SEARCH_xxx defines should not be used as if they were individual
bits. They represent a multi-bit enumeration value field.
Change-Id: I32abc9a475396dab02402a7014357dd94284e17b
---
M res/res_pjsip/pjsip_distributor.c
1 file changed, 18 insertions(+), 8 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/43/5943/1
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index cca26a8..2c9bcbf 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -837,7 +837,7 @@
/* Fall through */
case OBJ_SEARCH_KEY:
if (strcmp(object_left->src_name, right_key) == 0) {
- cmp = CMP_MATCH | CMP_STOP;
+ cmp = CMP_MATCH;
}
break;
case OBJ_SEARCH_PARTIAL_KEY:
@@ -852,15 +852,25 @@
return cmp;
}
-static int suspects_hash(const void *obj, int flags) {
- const struct unidentified_request *object_left = obj;
+static int suspects_hash(const void *obj, int flags)
+{
+ const struct unidentified_request *object;
+ const char *key;
- if (flags & OBJ_SEARCH_OBJECT) {
- return ast_str_hash(object_left->src_name);
- } else if (flags & OBJ_SEARCH_KEY) {
- return ast_str_hash(obj);
+ switch (flags & OBJ_SEARCH_MASK) {
+ case OBJ_SEARCH_KEY:
+ key = obj;
+ break;
+ case OBJ_SEARCH_OBJECT:
+ object = obj;
+ key = object->src_name;
+ break;
+ default:
+ /* Hash can only work on something with a full key. */
+ ast_assert(0);
+ return 0;
}
- return -1;
+ return ast_str_hash(key);
}
static struct ao2_container *cli_unid_get_container(const char *regex)
--
To view, visit https://gerrit.asterisk.org/5943
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: newchange
Gerrit-Change-Id: I32abc9a475396dab02402a7014357dd94284e17b
Gerrit-Change-Number: 5943
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170630/c04799fc/attachment.html>
More information about the asterisk-code-review
mailing list