Browse code

tm: Fix faked_reply_prio by passing correct reply to get_prio

Instead of passing the to be evaluated reply as the "best" reply, pass the
actual "best" reply.

(cherry picked from commit 5731cc0911ff65bf7efd433a83a25ffbf6073d10)
(cherry picked from commit cbd9c3d2851ece3c8f08b0664b72fca18f6f4f77)

Alex Hermann authored on 13/11/2017 14:50:20 • Daniel-Constantin Mierla committed on 30/10/2020 13:46:26
Showing 1 changed files
... ...
@@ -1171,17 +1171,19 @@ inline static short int get_prio(unsigned int resp, struct sip_msg *rpl)
1171 1171
 int t_pick_branch(int inc_branch, int inc_code, struct cell *t, int *res_code)
1172 1172
 {
1173 1173
 	int best_b, best_s, b;
1174
-	sip_msg_t *rpl;
1174
+	sip_msg_t *rpl, *best_rpl;
1175 1175
 
1176 1176
 	best_b=-1; best_s=0;
1177
+	best_rpl=NULL;
1177 1178
 	for ( b=0; b<t->nr_of_outgoings ; b++ ) {
1178 1179
 		rpl = t->uac[b].reply;
1179 1180
 
1180 1181
 		/* "fake" for the currently processed branch */
1181 1182
 		if (b==inc_branch) {
1182
-			if (get_prio(inc_code, rpl)<get_prio(best_s, rpl)) {
1183
+			if (get_prio(inc_code, rpl)<get_prio(best_s, best_rpl)) {
1183 1184
 				best_b=b;
1184 1185
 				best_s=inc_code;
1186
+				best_rpl=rpl;
1185 1187
 			}
1186 1188
 			continue;
1187 1189
 		}
... ...
@@ -1197,9 +1199,10 @@ int t_pick_branch(int inc_branch, int inc_code, struct cell *t, int *res_code)
1197 1199
 			return -2;
1198 1200
 		/* if reply is null => t_send_branch "faked" reply, skip over it */
1199 1201
 		if ( rpl &&
1200
-				get_prio(t->uac[b].last_received, rpl)<get_prio(best_s, rpl) ) {
1202
+				get_prio(t->uac[b].last_received, rpl)<get_prio(best_s, best_rpl) ) {
1201 1203
 			best_b =b;
1202 1204
 			best_s = t->uac[b].last_received;
1205
+			best_rpl=rpl;
1203 1206
 		}
1204 1207
 	} /* find lowest branch */
1205 1208