From bd1c47e995a3a844868f1d4dcc8f77f163ae721b Mon Sep 17 00:00:00 2001 From: Riza Sulistyo Date: Tue, 7 Jan 2014 10:55:10 +0000 Subject: Re #1721: Clear invite transaction before calling on_call_tsx_state (on transaction terminated) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4703 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_inv.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index cf3fc1ee..9778553c 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -655,6 +655,19 @@ static void mod_inv_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e) /* Call state handler for the invite session. */ (*inv_state_handler[inv->state])(inv, e); + /* Clear invite transaction when tsx is terminated. + * Necessary for app that wants to send a new re-INVITE request immediately + * after the transaction is terminated. + */ + if (tsx->state==PJSIP_TSX_STATE_TERMINATED && tsx == inv->invite_tsx) { + inv->invite_tsx = NULL; + + if (inv->last_answer) { + pjsip_tx_data_dec_ref(inv->last_answer); + inv->last_answer = NULL; + } + } + /* Call on_tsx_state. CANCEL request is a special case and has been * reported earlier in inv_respond_incoming_cancel() */ @@ -670,8 +683,9 @@ static void mod_inv_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e) * terminated, but this didn't work when ACK has the same Via branch * value as the INVITE (see http://www.pjsip.org/trac/ticket/113) */ - if (tsx->state>=PJSIP_TSX_STATE_CONFIRMED && tsx == inv->invite_tsx) { - inv->invite_tsx = NULL; + if (tsx->state>=PJSIP_TSX_STATE_CONFIRMED && tsx == inv->invite_tsx) { + inv->invite_tsx = NULL; + if (inv->last_answer) { pjsip_tx_data_dec_ref(inv->last_answer); inv->last_answer = NULL; -- cgit v1.2.3