diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-01-26 17:13:56 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-01-26 17:13:56 +0000 |
commit | e3cd40c8069f365a58fefe663d62e0222175e1c9 (patch) | |
tree | c5dad5ca9732abe4445b32d44d01b98651c59f42 /pjsip | |
parent | 6e952c9cd9a69c4f749da9de0b3d8af6e175150d (diff) |
Fixed ticket #81: registration refresh crashed when NIC is plugged-off
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@908 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/src/pjsip-ua/sip_reg.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index b5d1a6f7..45d2020c 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -525,6 +525,9 @@ static void call_callback(pjsip_regc *regc, pj_status_t status, int st_code, struct pjsip_regc_cbparam cbparam; + if (!regc->cb) + return; + cbparam.regc = regc; cbparam.token = regc->token; cbparam.status = status; @@ -550,17 +553,29 @@ static void regc_refresh_timer_cb( pj_timer_heap_t *timer_heap, PJ_UNUSED_ARG(timer_heap); + /* Temporarily increase busy flag to prevent regc from being deleted + * in pjsip_regc_send() + */ + regc->busy++; + entry->id = 0; status = pjsip_regc_register(regc, 1, &tdata); if (status == PJ_SUCCESS) { status = pjsip_regc_send(regc, tdata); } - if (status != PJ_SUCCESS) { + if (status != PJ_SUCCESS && regc->cb) { char errmsg[PJ_ERR_MSG_SIZE]; pj_str_t reason = pj_strerror(status, errmsg, sizeof(errmsg)); call_callback(regc, status, 400, &reason, NULL, -1, 0, NULL); } + + regc->busy--; + + /* Delete the record if user destroy regc during the callback. */ + if (regc->_delete_flag && regc->busy==0) { + pjsip_regc_destroy(regc); + } } static void tsx_callback(void *token, pjsip_event *event) |