Browse code

topos_redis: use tag based on direction for early dialog transaction record loading

- GH #3112

Daniel-Constantin Mierla authored on 24/06/2022 08:50:08
Showing 1 changed files
... ...
@@ -54,6 +54,11 @@ static str _tps_redis_dprefix = str_init("d:z:");
54 54
 
55 55
 static char _tps_redis_cbuf[TPS_REDIS_DATA_SIZE];
56 56
 
57
+static str _tps_redis_empty = str_init("");
58
+
59
+#define TPS_REDIS_STRZ(_s) ((_s).s)?(_s):(_tps_redis_empty)
60
+
61
+
57 62
 /**
58 63
  * storage keys
59 64
  */
... ...
@@ -594,6 +599,7 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
594 599
 	str skey = STR_NULL;
595 600
 	str sval = STR_NULL;
596 601
 	str xuuid = str_init("");
602
+	str xtag = str_init("");
597 603
 	str smethod = str_init("INVITE");
598 604
 
599 605
 	if(msg==NULL || md==NULL || sd==NULL)
... ...
@@ -615,6 +621,11 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
615 621
 	memset(argvlen, 0, TPS_REDIS_NR_KEYS * sizeof(size_t));
616 622
 	argc = 0;
617 623
 
624
+	if(md->direction==TPS_DIR_DOWNSTREAM) {
625
+		xtag = TPS_REDIS_STRZ(md->b_tag);
626
+	} else {
627
+		xtag = TPS_REDIS_STRZ(md->a_tag);
628
+	}
618 629
 	if(md->a_uuid.len>1) {
619 630
 		xuuid.s = md->a_uuid.s + 1;
620 631
 		xuuid.len = md->a_uuid.len - 1;
... ...
@@ -641,7 +652,7 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
641 652
 					_tps_redis_bprefix.len, _tps_redis_bprefix.s,
642 653
 					smethod.len, smethod.s,
643 654
 					md->a_callid.len, md->a_callid.s,
644
-					md->b_tag.len, md->b_tag.s,
655
+					xtag.len, xtag.s,
645 656
 					xuuid.len, xuuid.s);
646 657
 	if(rkey.len<0 || rkey.len>=TPS_REDIS_DATA_SIZE) {
647 658
 		LM_ERR("error or insufficient buffer size: %d\n", rkey.len);