Changeset 6087


Ignore:
Timestamp:
Oct 4, 2019 7:31:40 AM (5 years ago)
Author:
nanang
Message:

Fixed #2240:

  • Avoid double pjsip_inv_dec_ref() by evaluating the local var 'state' instead of 'inv->state' in checking DISCONNECTED state in 'inv_set_state()', as the 'on_state_changed()' callback may recursively call 'inv_set_state()' and shift the state to DISCONNECTED.
  • Avoid inv sess destroy in the callback by increasing ref count.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r5984 r6087  
    314314    inv->cb_called |= (1 << state); 
    315315 
    316     /* Call on_state_changed() callback. */ 
     316    /* Call on_state_changed() callback. 
     317     * While in the callback, can the state shift to DISCONNECTED? Perhaps 
     318     * yes, so better avoid premature destroy of the invite session by 
     319     * temporarily increase its ref counter. 
     320     */ 
     321    pjsip_inv_add_ref(inv); 
    317322    if (mod_inv.cb.on_state_changed && inv->notify && !dont_notify) 
    318323        (*mod_inv.cb.on_state_changed)(inv, e); 
     324    pjsip_inv_dec_ref(inv); 
    319325 
    320326    /* Only decrement when previous state is not already DISCONNECTED */ 
    321     if (inv->state == PJSIP_INV_STATE_DISCONNECTED && 
     327    if (state == PJSIP_INV_STATE_DISCONNECTED && 
    322328        prev_state != PJSIP_INV_STATE_DISCONNECTED)  
    323329    { 
Note: See TracChangeset for help on using the changeset viewer.