diff options
author | Benny Prijono <bennylp@teluu.com> | 2013-06-28 09:25:17 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2013-06-28 09:25:17 +0000 |
commit | 9adb4bb7f2d50e3651b9484214518c50a184e864 (patch) | |
tree | 5a128acf64c82527aa10e74aae52dff097fa0ae2 /pjsip/src | |
parent | c169efa79e2f8c4351682df39ad85a6fb2f0ead5 (diff) |
Fixed #1684 (Failed assertion when scheduling timer in the registration client):
- There is a potential race condition in pjsip_regc_set_delay_before_refresh() because it calls schedule_registration() without mutex protection
- Check if the timer is active and cancel it in schedule_registration() as precaution
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4548 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r-- | pjsip/src/pjsip-ua/sip_reg.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index efc209b6..3333317b 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -792,6 +792,9 @@ static void schedule_registration ( pjsip_regc *regc, pj_int32_t expiration ) if (regc->auto_reg && expiration > 0) { pj_time_val delay = { 0, 0}; + pj_timer_heap_cancel_if_active(pjsip_endpt_get_timer_heap(regc->endpt), + ®c->timer, 0); + delay.sec = expiration - regc->delay_before_refresh; if (regc->expires != PJSIP_REGC_EXPIRATION_NOT_SPECIFIED && delay.sec > (pj_int32_t)regc->expires) @@ -837,6 +840,8 @@ pjsip_regc_set_delay_before_refresh( pjsip_regc *regc, if (delay > regc->expires) return PJ_ETOOBIG; + pj_lock_acquire(regc->lock); + if (regc->delay_before_refresh != delay) { regc->delay_before_refresh = delay; @@ -851,6 +856,8 @@ pjsip_regc_set_delay_before_refresh( pjsip_regc *regc, } } + pj_lock_release(regc->lock); + return PJ_SUCCESS; } |