diff options
author | Liong Sauw Ming <ming@teluu.com> | 2015-03-03 07:52:36 +0000 |
---|---|---|
committer | Liong Sauw Ming <ming@teluu.com> | 2015-03-03 07:52:36 +0000 |
commit | 3126578bcb9ed8a0d2eb9e9f13e24dc80c117140 (patch) | |
tree | 3e4bcad0c79d83f5aa833707524cf214d43bc9f8 /pjsip/src/pjsip-ua | |
parent | 77334c81fc0f07c586ec6d1d28fcf0f5408aed87 (diff) |
Fixed #1819: Use expiration field to indicate registration/unregistration in registration callback
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4989 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip-ua')
-rw-r--r-- | pjsip/src/pjsip-ua/sip_reg.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index cca2526d..bdb0460b 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -88,6 +88,7 @@ struct pjsip_regc pjsip_contact_hdr removed_contact_hdr_list; pjsip_expires_hdr *expires_hdr; pj_uint32_t expires; + pj_uint32_t expires_requested; pj_uint32_t delay_before_refresh; pjsip_route_hdr route_set; pjsip_hdr hdr_list; @@ -213,7 +214,7 @@ PJ_DEF(pj_status_t) pjsip_regc_get_info( pjsip_regc *regc, info->next_reg = 0; else if (regc->auto_reg == 0) info->next_reg = 0; - else if (regc->expires < 0) + else if (regc->expires == PJSIP_REGC_EXPIRATION_NOT_SPECIFIED) info->next_reg = regc->expires; else { pj_time_val now, next_reg; @@ -550,6 +551,8 @@ PJ_DEF(pj_status_t) pjsip_regc_register(pjsip_regc *regc, pj_bool_t autoreg, PJ_ASSERT_RETURN(regc && p_tdata, PJ_EINVAL); pj_lock_acquire(regc->lock); + + regc->expires_requested = 1; status = create_request(regc, &tdata); if (status != PJ_SUCCESS) { @@ -621,6 +624,8 @@ PJ_DEF(pj_status_t) pjsip_regc_unregister(pjsip_regc *regc, regc->timer.id = 0; } + regc->expires_requested = 0; + status = create_request(regc, &tdata); if (status != PJ_SUCCESS) { pj_lock_release(regc->lock); @@ -742,7 +747,8 @@ static void cbparam_init( struct pjsip_regc_cbparam *cbparam, cbparam->reason = *reason; cbparam->rdata = rdata; cbparam->contact_cnt = contact_cnt; - cbparam->expiration = expiration; + cbparam->expiration = (expiration >= 0? expiration: + regc->expires_requested); if (contact_cnt) { pj_memcpy( cbparam->contact, contact, contact_cnt*sizeof(pjsip_contact_hdr*)); @@ -1392,6 +1398,9 @@ PJ_DEF(pj_status_t) pjsip_regc_send(pjsip_regc *regc, pjsip_tx_data *tdata) regc->current_op = REGC_UNREGISTERING; else regc->current_op = REGC_REGISTERING; + + if (expires_hdr && expires_hdr->ivalue) + regc->expires_requested = expires_hdr->ivalue; /* Prevent deletion of tdata, e.g: when something wrong in sending, * we need tdata to retrieve the transport. |