Browse code

rr: use msg_ctx_id_t for record route params caching

Daniel-Constantin Mierla authored on 13/08/2019 14:28:44
Showing 1 changed files
... ...
@@ -57,8 +57,7 @@
57 57
 #define ROUTE_SUFFIX_LEN (sizeof(ROUTE_SUFFIX)-1)
58 58
 
59 59
 /*! variables used to hook the param part of the local route */
60
-static unsigned int routed_msg_id = 0;
61
-static int routed_msg_pid = 0;
60
+static msg_ctx_id_t routed_msg_id = {0};
62 61
 static str routed_params = {0,0};
63 62
 
64 63
 extern int rr_force_send_socket;
... ...
@@ -585,8 +584,8 @@ static inline int after_strict(struct sip_msg* _m)
585 584
 	uri = rt->nameaddr.uri;
586 585
 
587 586
 	/* reset rr handling static vars for safety in error case */
588
-	routed_msg_id = 0;
589
-	routed_msg_pid = 0;
587
+	routed_msg_id.msgid = 0;
588
+	routed_msg_id.pid = 0;
590 589
 	routed_params.s = NULL;
591 590
 	routed_params.len = 0;
592 591
 
... ...
@@ -637,8 +636,8 @@ static inline int after_strict(struct sip_msg* _m)
637 636
 	/* set the hooks for the param
638 637
 	 * important note: RURI is already parsed by the above function, so 
639 638
 	 * we just used it without any checking */
640
-	routed_msg_id = _m->id;
641
-	routed_msg_pid = _m->pid;
639
+	routed_msg_id.msgid = _m->id;
640
+	routed_msg_id.pid = _m->pid;
642 641
 	routed_params = _m->parsed_uri.params;
643 642
 
644 643
 	if (is_strict(&puri.params)) {
... ...
@@ -794,8 +793,8 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
794 793
 	uri = rt->nameaddr.uri;
795 794
 
796 795
 	/* reset rr handling static vars for safety in error case */
797
-	routed_msg_id = 0;
798
-	routed_msg_pid = 0;
796
+	routed_msg_id.msgid = 0;
797
+	routed_msg_id.pid = 0;
799 798
 
800 799
 	if (parse_uri(uri.s, uri.len, &puri) < 0) {
801 800
 		LM_ERR("failed to parse the first route URI (%.*s)\n",
... ...
@@ -812,8 +811,8 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
812 811
 		LM_DBG("Topmost route URI: '%.*s' is me\n",
813 812
 			uri.len, ZSW(uri.s));
814 813
 		/* set the hooks for the params */
815
-		routed_msg_id = _m->id;
816
-		routed_msg_pid = _m->pid;
814
+		routed_msg_id.msgid = _m->id;
815
+		routed_msg_id.pid = _m->pid;
817 816
 
818 817
 		if ((use_ob = process_outbound(_m, puri.user)) < 0) {
819 818
 			LM_INFO("failed to process outbound flow-token\n");
... ...
@@ -1015,7 +1014,7 @@ int redo_route_params(sip_msg_t *msg)
1015 1014
 	}
1016 1015
 
1017 1016
 	/* check if the hooked params belong to the same message */
1018
-	if (routed_msg_id != msg->id || routed_msg_pid != msg->pid) {
1017
+	if (routed_msg_id.msgid != msg->id || routed_msg_id.pid != msg->pid) {
1019 1018
 		redo = 1;
1020 1019
 	}
1021 1020
 	if((redo==0) && (routed_params.s==NULL || routed_params.len<=0)) {
... ...
@@ -1031,8 +1030,8 @@ int redo_route_params(sip_msg_t *msg)
1031 1030
 		uri = rt->nameaddr.uri;
1032 1031
 
1033 1032
 		/* reset rr handling static vars for safety in error case */
1034
-		routed_msg_id = 0;
1035
-		routed_msg_pid = 0;
1033
+		routed_msg_id.msgid = 0;
1034
+		routed_msg_id.pid = 0;
1036 1035
 
1037 1036
 		if (parse_uri(uri.s, uri.len, &puri) < 0) {
1038 1037
 			LM_ERR("failed to parse the first route URI (%.*s)\n",
... ...
@@ -1047,8 +1046,8 @@ int redo_route_params(sip_msg_t *msg)
1047 1046
 			LM_DBG("Topmost route URI: '%.*s' is me\n",
1048 1047
 				uri.len, ZSW(uri.s));
1049 1048
 			/* set the hooks for the params */
1050
-			routed_msg_id = msg->id;
1051
-			routed_msg_pid = msg->pid;
1049
+			routed_msg_id.msgid = msg->id;
1050
+			routed_msg_id.pid = msg->pid;
1052 1051
 			routed_params = puri.params;
1053 1052
 			return 0;
1054 1053
 		} else {