Skip to content

Commit

Permalink
update cloned msg under lock to avoid races with new branches getting…
Browse files Browse the repository at this point in the history
… injected
  • Loading branch information
vladpaiu committed Nov 26, 2024
1 parent 9fed325 commit 206ced9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/tm/tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,11 +1294,6 @@ static int w_t_relay( struct sip_msg *p_msg , void *flags, struct proxy_l *prox
tm_has_request_disponsition_no_cancel(p_msg)==0 )
t->flags|=T_MULTI_200OK_FLAG;

/* update the transaction only if in REQUEST route; for other types
of routes we do not want to inherit the local changes */
if (route_type==REQUEST_ROUTE)
update_cloned_msg_from_msg( t->uas.request, p_msg);

if (route_type==FAILURE_ROUTE) {
/* If called from failure route we need reset the branch counter to
* ignore the previous set of branches (already terminated) */
Expand All @@ -1308,6 +1303,12 @@ static int w_t_relay( struct sip_msg *p_msg , void *flags, struct proxy_l *prox
* created, better lock here to avoid any overlapping with
* branch injection from other processes */
LOCK_REPLIES(t);

/* update the transaction only if in REQUEST route; for other types
of routes we do not want to inherit the local changes */
if (route_type==REQUEST_ROUTE)
update_cloned_msg_from_msg( t->uas.request, p_msg);

ret = t_forward_nonack( t, p_msg, p, 1/*reset*/,1/*locked*/);
UNLOCK_REPLIES(t);
}
Expand Down

0 comments on commit 206ced9

Please sign in to comment.