Browse code

tm: onreply_route: fix cleanup after DROP

After a DROP in the onreply_route the avp lists where not restored
to their original values and the possible msg flags changes in the
script were dropped.

Andrei Pelinescu-Onciul authored on 22/02/2010 17:01:26
Showing 1 changed files
... ...
@@ -2053,13 +2053,6 @@ int reply_received( struct sip_msg  *p_msg )
2053 2053
 		LOCK_REPLIES( t );
2054 2054
 		replies_locked=1;
2055 2055
 		run_top_route(onreply_rt.rlist[t->on_reply], p_msg, &ctx);
2056
-		if ((ctx.run_flags&DROP_R_F)  && (msg_status<200)) {
2057
-			if (unlikely(replies_locked)) {
2058
-				replies_locked = 0;
2059
-				UNLOCK_REPLIES( t );
2060
-			}
2061
-			goto done;
2062
-		}
2063 2056
 		/* transfer current message context back to t */
2064 2057
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
2065 2058
 		getbflagsval(0, &uac->branch_flags);
... ...
@@ -2074,6 +2067,16 @@ int reply_received( struct sip_msg  *p_msg )
2074 2074
 #ifdef WITH_XAVP
2075 2075
 		xavp_set_list(backup_xavps);
2076 2076
 #endif
2077
+		/* handle a possible DROP in the script, but only if this
2078
+		   is not a final reply (final replies already stop the timers
2079
+		   and droping them might leave a transaction living forever) */
2080
+		if ((ctx.run_flags&DROP_R_F)  && (msg_status<200)) {
2081
+			if (unlikely(replies_locked)) {
2082
+				replies_locked = 0;
2083
+				UNLOCK_REPLIES( t );
2084
+			}
2085
+			goto done;
2086
+		}
2077 2087
 	}
2078 2088
 #ifdef USE_DST_BLACKLIST
2079 2089
 		/* add temporary to the blacklist the source of a 503 reply */