Browse code

topos_redis: use initial transaction method for early dialog branch loading

Daniel-Constantin Mierla authored on 01/05/2021 12:38:36
Showing 1 changed files
... ...
@@ -588,6 +588,7 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
588 588
 	str skey = STR_NULL;
589 589
 	str sval = STR_NULL;
590 590
 	str xuuid = str_init("");
591
+	str smethod = str_init("INVITE");
591 592
 
592 593
 	if(msg==NULL || md==NULL || sd==NULL)
593 594
 		return -1;
... ...
@@ -622,12 +623,17 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
622 623
 		xuuid.len = sd->b_uuid.len - 1;
623 624
 	}
624 625
 
626
+	if(md->s_method_id & (METHOD_SUBSCRIBE|METHOD_NOTIFY)) {
627
+		smethod.s = "SUBSCRIBE";
628
+		smethod.len =9;
629
+	}
630
+
625 631
 	rp = _tps_redis_cbuf;
626 632
 
627 633
 	rkey.len = snprintf(rp, TPS_REDIS_DATA_SIZE,
628 634
 					"%.*s%.*s:%.*s:%.*s:x%.*s",
629 635
 					_tps_redis_bprefix.len, _tps_redis_bprefix.s,
630
-					md->s_method.len, md->s_method.s,
636
+					smethod.len, smethod.s,
631 637
 					md->a_callid.len, md->a_callid.s,
632 638
 					md->b_tag.len, md->b_tag.s,
633 639
 					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,
1161 1167
 		return -1;
1162 1168
 	}
1163 1169
 
1164
-	if(md->s_method.len==6 && strncmp(md->s_method.s, "INVITE", 6)==0) {
1165
-		if(tps_redis_insert_initial_method_branch(md, sd)<0) {
1166
-			LM_ERR("failed to insert INVITE extra branch data\n");
1167
-			return -1;
1168
-		}
1169
-	}
1170
-	if(md->s_method.len==9 && strncmp(md->s_method.s, "SUBSCRIBE", 9)==0) {
1170
+	if(md->s_method_id==METHOD_INVITE
1171
+			|| md->s_method_id==METHOD_SUBSCRIBE) {
1171 1172
 		if(tps_redis_insert_initial_method_branch(md, sd)<0) {
1172
-			LM_ERR("failed to insert SUBSCRIBE extra branch data\n");
1173
+			LM_ERR("failed to insert %.*s extra initial branch data\n",
1174
+					md->s_method.len, md->s_method.s);
1173 1175
 			return -1;
1174 1176
 		}
1175 1177
 	}