diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-01-21 16:11:18 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-01-21 16:11:18 +0000 |
commit | f0e1d077860ab17140fd52c54d0ac32015c93ee5 (patch) | |
tree | df5c15a832961196fcb11170c445707ae82494fc /pjsip | |
parent | 30b52da8afe33e39f4cf62e539546e7da04a8a65 (diff) |
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
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/src/pjsip-ua/sip_reg.c | 42 |
1 files 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; |