Skip to content

Commit

Permalink
tm: prevent concurrency between different cleanup
Browse files Browse the repository at this point in the history
This fixes a problem that was happening when having a transaction that
wasn't fully updated, for example in a Push Nofitication scenario where
no t_relay() was made, multiple messages may have reached the
do_t_cleanup() function in parallel, both updating the transaction.

Reported by 46Labs
  • Loading branch information
razvancrainea committed May 9, 2019
1 parent 3d081c8 commit deafdb7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/tm/tm.c
Expand Up @@ -712,10 +712,15 @@ static int do_t_cleanup( struct sip_msg *foo, void *bar)

reset_e2eack_t();

if ( (t=get_t())!=NULL && t!=T_UNDEFINED && /* we have a transaction */
/* with an UAS request not yet updated from script msg */
t->uas.request && (t->uas.request->msg_flags & FL_SHM_UPDATED)==0 )
update_cloned_msg_from_msg( t->uas.request, foo);
if ( (t=get_t())!=NULL && t!=T_UNDEFINED && t->uas.request) {
/* check the UAS request not yet updated from script msg */
LOCK_REPLIES(t);
if (t->uas.request->msg_flags & FL_SHM_UPDATED)
LM_DBG("transaction %p already updated! Skipping update!\n", t);
else
update_cloned_msg_from_msg( t->uas.request, foo);
UNLOCK_REPLIES(t);
}

return t_unref(foo) == 0 ? SCB_DROP_MSG : SCB_RUN_ALL;
}
Expand Down

0 comments on commit deafdb7

Please sign in to comment.