Changeset 5604 for pjproject


Ignore:
Timestamp:
Jun 14, 2017 6:04:12 AM (7 years ago)
Author:
nanang
Message:

Close #2009: Fixed issue no 2:

  • Synchronizing PJMEDIA transport ICE and ICE stream transport lifetime using group lock.
  • Zeroing callback pointer in ICE stream transport destructor.
  • Added few pointer validity checks.
Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c

    r5597 r5604  
    159159                                pj_status_t status); 
    160160 
     161/* 
     162 * Clean up ICE resources. 
     163 */ 
     164static void tp_ice_on_destroy(void *arg); 
     165 
    161166 
    162167static pjmedia_transport_op transport_ice_op =  
     
    289294        *p_tp = NULL; 
    290295        return status; 
     296    } 
     297 
     298    /* Sync to ICE */ 
     299    { 
     300        pj_grp_lock_t *grp_lock = pj_ice_strans_get_grp_lock(tp_ice->ice_st); 
     301        pj_grp_lock_add_ref(grp_lock); 
     302        pj_grp_lock_add_handler(grp_lock, pool, tp_ice, &tp_ice_on_destroy); 
    291303    } 
    292304 
     
    17891801 
    17901802    tp_ice = (struct transport_ice*) pj_ice_strans_get_user_data(ice_st); 
     1803    if (!tp_ice) { 
     1804        /* Destroy on progress */ 
     1805        return; 
     1806    } 
    17911807 
    17921808    if (comp_id==1 && tp_ice->rtp_cb) { 
     
    19261942 
    19271943    tp_ice = (struct transport_ice*) pj_ice_strans_get_user_data(ice_st); 
     1944    if (!tp_ice) { 
     1945        /* Destroy on progress */ 
     1946        return; 
     1947    } 
    19281948 
    19291949    pj_perror(5, tp_ice->base.name, result, "ICE operation complete" 
     
    19651985} 
    19661986 
     1987static void tp_ice_on_destroy(void *arg) 
     1988{ 
     1989    struct transport_ice *tp_ice = (struct transport_ice*)arg; 
     1990    pj_pool_safe_release(&tp_ice->pool); 
     1991} 
    19671992 
    19681993/* 
     
    19731998    struct transport_ice *tp_ice = (struct transport_ice*)tp; 
    19741999 
     2000    /* Reset callback and user data */ 
     2001    pj_bzero(&tp_ice->cb, sizeof(tp_ice->cb)); 
     2002    tp_ice->base.user_data = NULL; 
     2003    tp_ice->rtp_cb = NULL; 
     2004    tp_ice->rtcp_cb = NULL; 
     2005 
    19752006    if (tp_ice->ice_st) { 
     2007        pj_grp_lock_t *grp_lock = pj_ice_strans_get_grp_lock(tp_ice->ice_st); 
    19762008        pj_ice_strans_destroy(tp_ice->ice_st); 
    19772009        tp_ice->ice_st = NULL; 
    1978     } 
    1979  
    1980     pj_pool_safe_release(&tp_ice->pool); 
     2010        pj_grp_lock_dec_ref(grp_lock); 
     2011    } else { 
     2012        tp_ice_on_destroy(tp); 
     2013    } 
    19812014 
    19822015    return PJ_SUCCESS; 
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r5562 r5604  
    863863    pj_log_push_indent(); 
    864864 
     865    /* Reset callback and user data */ 
     866    pj_bzero(&ice_st->cb, sizeof(ice_st->cb)); 
     867    ice_st->user_data = NULL; 
     868 
    865869    pj_grp_lock_acquire(ice_st->grp_lock); 
    866870 
     
    955959    unsigned i; 
    956960 
    957     /* Ignore if init callback has been called */ 
    958     if (ice_st->cb_called) 
     961    /* Ignore if ICE is destroying or init callback has been called */ 
     962    if (ice_st->destroy_req || ice_st->cb_called) 
    959963        return; 
    960964 
Note: See TracChangeset for help on using the changeset viewer.