From 4af4b1d18fc506d4a6cbe23a3266531ce08e9514 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 24 Jun 2011 07:35:28 +0000 Subject: Fixed #1318: Prevent PJSIP_INV_STATE_CALLING from being reported more than once (thanks Sam Yasin for the report) git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3598 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_inv.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'pjsip/src/pjsip-ua/sip_inv.c') diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index 377dc147..b377beb4 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -195,8 +195,18 @@ void inv_set_state(pjsip_inv_session *inv, pjsip_inv_state state, pjsip_event *e) { pjsip_inv_state prev_state = inv->state; + pj_bool_t dont_notify = PJ_FALSE; pj_status_t status; + /* Prevent STATE_CALLING from being reported more than once because + * of authentication + * https://trac.pjsip.org/repos/ticket/1318 + */ + if (state==PJSIP_INV_STATE_CALLING && + (inv->cb_called & (1 << PJSIP_INV_STATE_CALLING)) != 0) + { + dont_notify = PJ_TRUE; + } /* If state is confirmed, check that SDP negotiation is done, * otherwise disconnect the session. @@ -224,8 +234,11 @@ void inv_set_state(pjsip_inv_session *inv, pjsip_inv_state state, pj_assert(inv->state != PJSIP_INV_STATE_DISCONNECTED || inv->cause != 0); + /* Mark the callback as called for this state */ + inv->cb_called |= (1 << state); + /* Call on_state_changed() callback. */ - if (mod_inv.cb.on_state_changed && inv->notify) + if (mod_inv.cb.on_state_changed && inv->notify && !dont_notify) (*mod_inv.cb.on_state_changed)(inv, e); /* Only decrement when previous state is not already DISCONNECTED */ -- cgit v1.2.3