Changeset 2948 for pjproject/trunk


Ignore:
Timestamp:
Oct 15, 2009 4:46:39 AM (15 years ago)
Author:
bennylp
Message:

Fixed ticket #974: Crash if ICE session is destroyed by the application inside "on_ice_complete" with an PJ_ICE_STRANS_OP_NEGOTIATION op callback (thanks John Ridges for the report)

File:
1 edited

Legend:

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

    r2944 r2948  
    11001100    pj_ice_sess *ice = (pj_ice_sess*) te->user_data; 
    11011101    enum timer_type type = (enum timer_type)te->id; 
     1102    pj_bool_t has_mutex = PJ_TRUE; 
    11021103 
    11031104    PJ_UNUSED_ARG(th); 
     
    11151116        break; 
    11161117    case TIMER_COMPLETION_CALLBACK: 
    1117         /* Start keep-alive timer but don't send any packets yet. 
    1118          * Need to do it here just in case app destroy the session 
    1119          * in the callback. 
    1120          */ 
    1121         if (ice->ice_status == PJ_SUCCESS) 
    1122             ice_keep_alive(ice, PJ_FALSE); 
    1123  
    1124         /* Notify app about ICE completion*/ 
    1125         if (ice->cb.on_ice_complete) 
    1126             (*ice->cb.on_ice_complete)(ice, ice->ice_status); 
     1118        { 
     1119            void (*on_ice_complete)(pj_ice_sess *ice, pj_status_t status); 
     1120            pj_status_t ice_status; 
     1121 
     1122            /* Start keep-alive timer but don't send any packets yet. 
     1123             * Need to do it here just in case app destroy the session 
     1124             * in the callback. 
     1125             */ 
     1126            if (ice->ice_status == PJ_SUCCESS) 
     1127                ice_keep_alive(ice, PJ_FALSE); 
     1128 
     1129            /* Release mutex in case app destroy us in the callback */ 
     1130            ice_status = ice->ice_status; 
     1131            on_ice_complete = ice->cb.on_ice_complete; 
     1132            has_mutex = PJ_FALSE; 
     1133            pj_mutex_unlock(ice->mutex); 
     1134 
     1135            /* Notify app about ICE completion*/ 
     1136            if (on_ice_complete) 
     1137                (*on_ice_complete)(ice, ice_status); 
     1138        } 
    11271139        break; 
    11281140    case TIMER_START_NOMINATED_CHECK: 
     
    11371149    } 
    11381150 
    1139     pj_mutex_unlock(ice->mutex); 
     1151    if (has_mutex) 
     1152        pj_mutex_unlock(ice->mutex); 
    11401153} 
    11411154 
Note: See TracChangeset for help on using the changeset viewer.