From 9adb4bb7f2d50e3651b9484214518c50a184e864 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 28 Jun 2013 09:25:17 +0000 Subject: 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 --- pjsip/src/pjsip-ua/sip_reg.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'pjsip') 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; } -- cgit v1.2.3