Quellcode durchsuchen

tm: store last received response code before running onreply_route

- otherwise an innapropriate cancel can happen if the current branch got
  before an 1xx response, and the script writer enforces another reply
  code with t_reply()
- reported by Thomas Sevestre, GH#315
Daniel-Constantin Mierla vor 10 Jahren
Ursprung
Commit
b7c588dff0
1 geänderte Dateien mit 11 neuen und 0 gelöschten Zeilen
  1. 11 0
      modules/tm/t_reply.c

+ 11 - 0
modules/tm/t_reply.c

@@ -2286,10 +2286,21 @@ int reply_received( struct sip_msg  *p_msg )
 		backup_xavps = xavp_set_list(&t->xavps_list);
 #endif
 		setbflagsval(0, uac->branch_flags);
+		if(msg_status>last_uac_status) {
+			/* current response (msg) status is higher that the last received
+			 * on the same branch - set it temporarily so functions in onreply_route
+			 * can access it (e.g., avoid sending CANCEL by forcing another t_relply()
+			 * in onreply_route when a negative sip response was received) */
+			uac->last_received = msg_status;
+		}
+
 		/* Pre- and post-script callbacks have already
 		 * been executed by the core. (Miklos)
 		 */
 		run_top_route(onreply_rt.rlist[onreply_route], p_msg, &ctx);
+
+		/* restore brach last_received as before executing onreply_route */
+		uac->last_received = last_uac_status;
 		/* transfer current message context back to t */
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
 		getbflagsval(0, &uac->branch_flags);