[sr-dev] git:5.5:3f5c99f1: topos_redis: use initial transaction method for early dialog branch loading

Daniel-Constantin Mierla miconda at gmail.com
Mon May 3 10:05:56 CEST 2021


Module: kamailio
Branch: 5.5
Commit: 3f5c99f1bb3bbfdfb84416e7850f379e7a151e15
URL: https://github.com/kamailio/kamailio/commit/3f5c99f1bb3bbfdfb84416e7850f379e7a151e15

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-05-03T09:44:35+02:00

topos_redis: use initial transaction method for early dialog branch loading

(cherry picked from commit 824920d5b159d80ce3c241313bf647b5dbbf6661)

---

Modified: src/modules/topos_redis/topos_redis_storage.c

---

Diff:  https://github.com/kamailio/kamailio/commit/3f5c99f1bb3bbfdfb84416e7850f379e7a151e15.diff
Patch: https://github.com/kamailio/kamailio/commit/3f5c99f1bb3bbfdfb84416e7850f379e7a151e15.patch

---

diff --git a/src/modules/topos_redis/topos_redis_storage.c b/src/modules/topos_redis/topos_redis_storage.c
index d63543dc38..c2d43b4c33 100644
--- a/src/modules/topos_redis/topos_redis_storage.c
+++ b/src/modules/topos_redis/topos_redis_storage.c
@@ -588,6 +588,7 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
 	str skey = STR_NULL;
 	str sval = STR_NULL;
 	str xuuid = str_init("");
+	str smethod = str_init("INVITE");
 
 	if(msg==NULL || md==NULL || sd==NULL)
 		return -1;
@@ -622,12 +623,17 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
 		xuuid.len = sd->b_uuid.len - 1;
 	}
 
+	if(md->s_method_id & (METHOD_SUBSCRIBE|METHOD_NOTIFY)) {
+		smethod.s = "SUBSCRIBE";
+		smethod.len =9;
+	}
+
 	rp = _tps_redis_cbuf;
 
 	rkey.len = snprintf(rp, TPS_REDIS_DATA_SIZE,
 					"%.*s%.*s:%.*s:%.*s:x%.*s",
 					_tps_redis_bprefix.len, _tps_redis_bprefix.s,
-					md->s_method.len, md->s_method.s,
+					smethod.len, smethod.s,
 					md->a_callid.len, md->a_callid.s,
 					md->b_tag.len, md->b_tag.s,
 					xuuid.len, xuuid.s);
@@ -1161,15 +1167,11 @@ int tps_redis_update_branch(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd,
 		return -1;
 	}
 
-	if(md->s_method.len==6 && strncmp(md->s_method.s, "INVITE", 6)==0) {
-		if(tps_redis_insert_initial_method_branch(md, sd)<0) {
-			LM_ERR("failed to insert INVITE extra branch data\n");
-			return -1;
-		}
-	}
-	if(md->s_method.len==9 && strncmp(md->s_method.s, "SUBSCRIBE", 9)==0) {
+	if(md->s_method_id==METHOD_INVITE
+			|| md->s_method_id==METHOD_SUBSCRIBE) {
 		if(tps_redis_insert_initial_method_branch(md, sd)<0) {
-			LM_ERR("failed to insert SUBSCRIBE extra branch data\n");
+			LM_ERR("failed to insert %.*s extra initial branch data\n",
+					md->s_method.len, md->s_method.s);
 			return -1;
 		}
 	}




More information about the sr-dev mailing list