Ignore:
Timestamp:
Jan 8, 2019 9:07:47 AM (6 years ago)
Author:
nanang
Message:

Fixed #2172: Avoid double reference counter decrements in timer in the scenario of race condition between pj_timer_heap_cancel() and pj_timer_heap_poll().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/timer.c

    r5720 r5927  
    581581    lock_timer_heap(ht); 
    582582    count = cancel(ht, entry, flags | F_DONT_CALL); 
    583     if (flags & F_SET_ID) { 
    584         entry->id = id_val; 
    585     } 
    586     if (entry->_grp_lock) { 
    587         pj_grp_lock_t *grp_lock = entry->_grp_lock; 
    588         entry->_grp_lock = NULL; 
    589         pj_grp_lock_dec_ref(grp_lock); 
     583    if (count > 0) { 
     584        /* Timer entry found & cancelled */ 
     585        if (flags & F_SET_ID) { 
     586            entry->id = id_val; 
     587        } 
     588        if (entry->_grp_lock) { 
     589            pj_grp_lock_t *grp_lock = entry->_grp_lock; 
     590            entry->_grp_lock = NULL; 
     591            pj_grp_lock_dec_ref(grp_lock); 
     592        } 
    590593    } 
    591594    unlock_timer_heap(ht); 
Note: See TracChangeset for help on using the changeset viewer.