From f0e1d077860ab17140fd52c54d0ac32015c93ee5 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sun, 21 Jan 2007 16:11:18 +0000 Subject: Fixed ticket #73: regc does not respond to 401/407 challenge after it has been marked for deletion git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@891 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_reg.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index d6078c73..b5d1a6f7 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -573,16 +573,9 @@ static void tsx_callback(void *token, pjsip_event *event) pj_assert(regc->has_tsx); regc->has_tsx = PJ_FALSE; - /* If registration data has been deleted by user then remove registration - * data from transaction's callback, and don't call callback. - */ - if (regc->_delete_flag) { - - /* Nothing to do */ - ; - - } else if (tsx->status_code == PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED || - tsx->status_code == PJSIP_SC_UNAUTHORIZED) + /* Handle 401/407 challenge (even when _delete_flag is set) */ + if (tsx->status_code == PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED || + tsx->status_code == PJSIP_SC_UNAUTHORIZED) { pjsip_rx_data *rdata = event->body.tsx_state.src.rdata; pjsip_tx_data *tdata; @@ -597,12 +590,33 @@ static void tsx_callback(void *token, pjsip_event *event) } if (status != PJ_SUCCESS) { - call_callback(regc, status, tsx->status_code, - &rdata->msg_info.msg->line.status.reason, - rdata, -1, 0, NULL); + + /* Only call callback if application is still interested + * in it. + */ + if (regc->_delete_flag == 0) { + /* Increment busy flag temporarily to prevent regc from + * being destroyed. + */ + ++regc->busy; + + call_callback(regc, status, tsx->status_code, + &rdata->msg_info.msg->line.status.reason, + rdata, -1, 0, NULL); + + /* Decrement busy flag */ + --regc->busy; + } } - return; + } else if (regc->_delete_flag) { + + /* User has called pjsip_regc_destroy(), so don't call callback. + * This regc will be destroyed later in this function. + */ + + /* Nothing to do */ + ; } else { int contact_cnt = 0; -- cgit v1.2.3