[asterisk-commits] pjsip distributor.c: Fix unidentified requests hash functions. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 5 15:07:51 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5942 )

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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index dadde25..7778353 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -827,7 +827,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:
@@ -842,15 +842,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/5942
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I32abc9a475396dab02402a7014357dd94284e17b
Gerrit-Change-Number: 5942
Gerrit-PatchSet: 2
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170705/c7b869ce/attachment-0001.html>


More information about the asterisk-commits mailing list