Changeset 5151


Ignore:
Timestamp:
Aug 7, 2015 5:44:40 AM (9 years ago)
Author:
ming
Message:

Fixed #1877: Race condition between stopping ICE and sending data in ICE stream transport

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r5035 r5151  
    11501150{ 
    11511151    PJ_ASSERT_RETURN(ice_st, PJ_EINVAL); 
     1152     
     1153    /* Protect with group lock, since this may cause race condition with 
     1154     * pj_ice_strans_sendto(). 
     1155     * See ticket #1877. 
     1156     */ 
     1157    pj_grp_lock_acquire(ice_st->grp_lock); 
    11521158 
    11531159    if (ice_st->ice) { 
     
    11571163 
    11581164    ice_st->state = PJ_ICE_STRANS_STATE_INIT; 
     1165 
     1166    pj_grp_lock_release(ice_st->grp_lock); 
     1167 
    11591168    return PJ_SUCCESS; 
    11601169} 
     
    11831192    if (def_cand >= comp->cand_cnt) 
    11841193        return PJ_EINVALIDOP; 
     1194 
     1195    /* Protect with group lock, since this may cause race condition with 
     1196     * pj_ice_strans_stop_ice(). 
     1197     * See ticket #1877. 
     1198     */ 
     1199    pj_grp_lock_acquire(ice_st->grp_lock); 
    11851200 
    11861201    /* If ICE is available, send data with ICE, otherwise send with the 
     
    11911206     */ 
    11921207    if (ice_st->ice && ice_st->state == PJ_ICE_STRANS_STATE_RUNNING) { 
    1193         if (comp->turn_sock) { 
    1194             pj_turn_sock_lock(comp->turn_sock); 
    1195         } 
    11961208        status = pj_ice_sess_send_data(ice_st->ice, comp_id, data, data_len); 
    1197         if (comp->turn_sock) { 
    1198             pj_turn_sock_unlock(comp->turn_sock); 
    1199         } 
     1209         
     1210        pj_grp_lock_release(ice_st->grp_lock); 
     1211         
    12001212        return status; 
    1201  
    1202     } else if (comp->cand_list[def_cand].status == PJ_SUCCESS) { 
     1213    }  
     1214     
     1215    pj_grp_lock_release(ice_st->grp_lock); 
     1216     
     1217    if (comp->cand_list[def_cand].status == PJ_SUCCESS) { 
    12031218 
    12041219        if (comp->cand_list[def_cand].type == PJ_ICE_CAND_TYPE_RELAYED) { 
Note: See TracChangeset for help on using the changeset viewer.