Browse code

topos_redis: use uuid for initial transaction indexing

(cherry picked from commit 5707f9ef7f6a0d9b9bcd00ff85168b977591a30a)

Daniel-Constantin Mierla authored on 01/05/2021 06:07:08
Showing 1 changed files
... ...
@@ -314,6 +314,7 @@ int tps_redis_insert_initial_method_branch(tps_data_t *td)
314 314
 	redisc_server_t *rsrv = NULL;
315 315
 	redisReply *rrpl = NULL;
316 316
 	unsigned long lval = 0;
317
+	str xuuid = str_init("");
317 318
 
318 319
 	if(td->x_vbranch1.len<=0) {
319 320
 		LM_INFO("no via branch for this message\n");
... ...
@@ -331,13 +332,22 @@ int tps_redis_insert_initial_method_branch(tps_data_t *td)
331 332
 	memset(argvlen, 0, TPS_REDIS_NR_KEYS * sizeof(size_t));
332 333
 	argc = 0;
333 334
 
335
+	if(td->a_uuid.len>1) {
336
+		xuuid.s = td->a_uuid.s + 1;
337
+		xuuid.len = td->a_uuid.len - 1;
338
+	} else if(td->b_uuid.len>1) {
339
+		xuuid.s = td->b_uuid.s + 1;
340
+		xuuid.len = td->b_uuid.len - 1;
341
+	}
342
+
334 343
 	rp = _tps_redis_cbuf;
335 344
 	rkey.len = snprintf(rp, TPS_REDIS_DATA_SIZE-128,
336
-					"%.*s%.*s:%.*s:%.*s",
345
+					"%.*s%.*s:%.*s:%.*s:x%.*s",
337 346
 					_tps_redis_bprefix.len, _tps_redis_bprefix.s,
338 347
 					td->s_method.len, td->s_method.s,
339 348
 					td->a_callid.len, td->a_callid.s,
340
-					td->b_tag.len, td->b_tag.s);
349
+					td->b_tag.len, td->b_tag.s,
350
+					xuuid.len, xuuid.s);
341 351
 	if(rkey.len<0 || rkey.len>=TPS_REDIS_DATA_SIZE-128) {
342 352
 		LM_ERR("error or insufficient buffer size: %d\n", rkey.len);
343 353
 		return -1;
... ...
@@ -571,6 +581,7 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
571 581
 	redisReply *rrpl = NULL;
572 582
 	str skey = STR_NULL;
573 583
 	str sval = STR_NULL;
584
+	str xuuid = str_init("");
574 585
 
575 586
 	if(msg==NULL || md==NULL || sd==NULL)
576 587
 		return -1;
... ...
@@ -591,14 +602,23 @@ int tps_redis_load_initial_method_branch(sip_msg_t *msg, tps_data_t *md, tps_dat
591 602
 	memset(argvlen, 0, TPS_REDIS_NR_KEYS * sizeof(size_t));
592 603
 	argc = 0;
593 604
 
605
+	if(md->a_uuid.len>1) {
606
+		xuuid.s = md->a_uuid.s + 1;
607
+		xuuid.len = md->a_uuid.len - 1;
608
+	} else if(md->b_uuid.len>1) {
609
+		xuuid.s = md->b_uuid.s + 1;
610
+		xuuid.len = md->b_uuid.len - 1;
611
+	}
612
+
594 613
 	rp = _tps_redis_cbuf;
595 614
 
596 615
 	rkey.len = snprintf(rp, TPS_REDIS_DATA_SIZE,
597
-					"%.*s%.*s:%.*s:%.*s",
616
+					"%.*s%.*s:%.*s:%.*s:x%.*s",
598 617
 					_tps_redis_bprefix.len, _tps_redis_bprefix.s,
599 618
 					md->s_method.len, md->s_method.s,
600 619
 					md->a_callid.len, md->a_callid.s,
601
-					md->b_tag.len, md->b_tag.s);
620
+					md->b_tag.len, md->b_tag.s,
621
+					xuuid.len, xuuid.s);
602 622
 	if(rkey.len<0 || rkey.len>=TPS_REDIS_DATA_SIZE) {
603 623
 		LM_ERR("error or insufficient buffer size: %d\n", rkey.len);
604 624
 		return -1;