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