From af0b29f972d2b03778daa66048a124428eb8d3d0 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sat, 18 Feb 2012 02:12:22 +0000 Subject: Fixed #1452: Wrong call media state is reported if hold request is challenged with authentication (thanks Bogdan Krakowski for the fix) git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3954 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsip/sip_transport.h | 7 +++++++ pjsip/src/pjsip/sip_auth_client.c | 6 +++++- pjsip/src/pjsua-lib/pjsua_call.c | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) (limited to 'pjsip') diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h index a567d1a1..99f006a6 100644 --- a/pjsip/include/pjsip/sip_transport.h +++ b/pjsip/include/pjsip/sip_transport.h @@ -573,6 +573,13 @@ struct pjsip_tx_data */ pjsip_tpselector tp_sel; + /** + * Special flag to indicate that this transmit data is a request that has + * been updated with proper authentication response and is ready to be + * sent for retry. + */ + pj_bool_t auth_retry; + /** * Arbitrary data attached by PJSIP modules. */ diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c index 8684cc9b..4bde8539 100644 --- a/pjsip/src/pjsip/sip_auth_client.c +++ b/pjsip/src/pjsip/sip_auth_client.c @@ -1103,7 +1103,8 @@ PJ_DEF(pj_status_t) pjsip_auth_clt_reinit_req( pjsip_auth_clt_sess *sess, PJSIP_EINVALIDSTATUS); tdata = old_request; - + tdata->auth_retry = PJ_FALSE; + /* * Respond to each authentication challenge. */ @@ -1174,6 +1175,9 @@ PJ_DEF(pj_status_t) pjsip_auth_clt_reinit_req( pjsip_auth_clt_sess *sess, /* Must invalidate the message! */ pjsip_tx_data_invalidate_msg(tdata); + /* Retrying.. */ + tdata->auth_retry = PJ_TRUE; + /* Increment reference counter. */ pjsip_tx_data_add_ref(tdata); diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 532bc12b..ed25da59 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -4326,6 +4326,18 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv, return; } + /* https://trac.pjsip.org/repos/ticket/1452: + * If a request is retried due to 401/407 challenge, don't process the + * transaction first but wait until we've retried it. + */ + if (tsx->role == PJSIP_ROLE_UAC && + (tsx->status_code==401 || tsx->status_code==407) && + tsx->last_tx && tsx->last_tx->auth_retry) + { + PJSUA_UNLOCK(); + return; + } + /* Notify application callback first */ if (pjsua_var.ua_cfg.cb.on_call_tsx_state) { (*pjsua_var.ua_cfg.cb.on_call_tsx_state)(call->index, tsx, e); -- cgit v1.2.3