Changeset 4449 for pjproject


Ignore:
Timestamp:
Mar 22, 2013 3:16:35 AM (11 years ago)
Author:
bennylp
Message:

Fixed #1648: Timer heap new API cancel_if_active() should not assert if given bad entry

File:
1 edited

Legend:

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

    r4359 r4449  
    4646#define DEFAULT_MAX_TIMED_OUT_PER_POLL  (64) 
    4747 
     48enum 
     49{ 
     50    F_DONT_CALL = 1, 
     51    F_DONT_ASSERT = 2, 
     52    F_SET_ID = 4 
     53}; 
     54 
    4855 
    4956/** 
     
    314321static int cancel( pj_timer_heap_t *ht,  
    315322                   pj_timer_entry *entry,  
    316                    int dont_call) 
     323                   unsigned flags) 
    317324{ 
    318325  long timer_node_slot; 
     
    331338  if (entry != ht->heap[timer_node_slot]) 
    332339    { 
    333       pj_assert(entry == ht->heap[timer_node_slot]); 
     340      if ((flags & F_DONT_ASSERT) == 0) 
     341          pj_assert(entry == ht->heap[timer_node_slot]); 
    334342      return 0; 
    335343    } 
     
    338346      remove_node( ht, timer_node_slot); 
    339347 
    340       if (dont_call == 0) 
     348      if ((flags & F_DONT_CALL) == 0) 
    341349        // Call the close hook. 
    342350        (*ht->callback)(ht, entry); 
     
    552560static int cancel_timer(pj_timer_heap_t *ht, 
    553561                        pj_timer_entry *entry, 
    554                         pj_bool_t set_id, 
     562                        unsigned flags, 
    555563                        int id_val) 
    556564{ 
     
    560568 
    561569    lock_timer_heap(ht); 
    562     count = cancel(ht, entry, 1); 
    563     if (set_id) { 
     570    count = cancel(ht, entry, flags | F_DONT_CALL); 
     571    if (flags & F_SET_ID) { 
    564572        entry->id = id_val; 
    565573    } 
     
    577585                                  pj_timer_entry *entry) 
    578586{ 
    579     return cancel_timer(ht, entry, PJ_FALSE, 0); 
     587    return cancel_timer(ht, entry, 0, 0); 
    580588} 
    581589 
     
    584592                                           int id_val) 
    585593{ 
    586     return cancel_timer(ht, entry, PJ_TRUE, id_val); 
     594    return cancel_timer(ht, entry, F_SET_ID | F_DONT_ASSERT, id_val); 
    587595} 
    588596 
Note: See TracChangeset for help on using the changeset viewer.