From 9bd5e4dd99a742c764fa5839a7d5ff88c7bafc56 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 4 Jun 2014 09:23:10 +0000 Subject: Misc (re #1751): invalidate timer entry for every cancel() scenario to avoid assertion next time the entry is scheduled if cancellation fails (thanks Johan Lantz for the report) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4855 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pj/timer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pjlib/src') diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c index 931a57fa..225be449 100644 --- a/pjlib/src/pj/timer.c +++ b/pjlib/src/pj/timer.c @@ -328,18 +328,23 @@ static int cancel( pj_timer_heap_t *ht, PJ_CHECK_STACK(); // Check to see if the timer_id is out of range - if (entry->_timer_id < 0 || (pj_size_t)entry->_timer_id > ht->max_size) + if (entry->_timer_id < 0 || (pj_size_t)entry->_timer_id > ht->max_size) { + entry->_timer_id = -1; return 0; + } timer_node_slot = ht->timer_ids[entry->_timer_id]; - if (timer_node_slot < 0) // Check to see if timer_id is still valid. + if (timer_node_slot < 0) { // Check to see if timer_id is still valid. + entry->_timer_id = -1; return 0; + } if (entry != ht->heap[timer_node_slot]) { if ((flags & F_DONT_ASSERT) == 0) pj_assert(entry == ht->heap[timer_node_slot]); + entry->_timer_id = -1; return 0; } else -- cgit v1.2.3