Changeset 5765


Ignore:
Timestamp:
Apr 2, 2018 5:43:58 AM (7 years ago)
Author:
riza
Message:

Re #2104: Make sure that STUN session is destroyed and prevent new timer for
STUN destruction on pjsua_destroy2().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r5762 r5765  
    12341234 
    12351235 
    1236 static void destroy_stun_resolve_cb(pj_timer_heap_t *t, pj_timer_entry *e) 
    1237 { 
    1238     pjsua_stun_resolve *sess = (pjsua_stun_resolve*)e->user_data; 
    1239     PJ_UNUSED_ARG(t); 
    1240  
     1236static void release_stun_session(pjsua_stun_resolve *sess) 
     1237{ 
    12411238    PJSUA_LOCK(); 
    12421239    pj_list_erase(sess); 
     
    12471244} 
    12481245 
    1249  
    1250 static void destroy_stun_resolve(pjsua_stun_resolve *sess) 
     1246static void destroy_stun_resolve_cb(pj_timer_heap_t *t, pj_timer_entry *e) 
     1247{ 
     1248    pjsua_stun_resolve *sess = (pjsua_stun_resolve*)e->user_data; 
     1249    PJ_UNUSED_ARG(t); 
     1250 
     1251    release_stun_session(sess); 
     1252} 
     1253 
     1254 
     1255static void destroy_stun_resolve(pjsua_stun_resolve *sess, pj_bool_t forced) 
    12511256{ 
    12521257    pj_time_val timeout = {0, 0}; 
     
    12661271        pjsua_var.stun_status = PJNATH_ESTUNDESTROYED; 
    12671272    } 
    1268      
    1269     /* Schedule session clean up, it needs PJSUA lock and locking it here 
    1270      * may cause deadlock as this function may be called by STUN socket 
    1271      * while holding STUN socket lock, while application may wait for STUN 
    1272      * resolution while holding PJSUA lock. 
    1273      */ 
    1274     pj_timer_entry_init(&sess->timer, 0, (void*)sess, 
    1275                         &destroy_stun_resolve_cb); 
    1276     pjsua_schedule_timer(&sess->timer, &timeout); 
     1273 
     1274    if (forced) { 
     1275        release_stun_session(sess); 
     1276    } else { 
     1277        /* Schedule session clean up, it needs PJSUA lock and locking it here 
     1278         * may cause deadlock as this function may be called by STUN socket 
     1279         * while holding STUN socket lock, while application may wait for STUN 
     1280         * resolution while holding PJSUA lock. 
     1281         */ 
     1282        pj_timer_entry_init(&sess->timer, 0, (void*)sess, 
     1283                            &destroy_stun_resolve_cb); 
     1284        pjsua_schedule_timer(&sess->timer, &timeout); 
     1285    } 
    12771286} 
    12781287 
     
    12891298    } 
    12901299 
    1291     destroy_stun_resolve(sess); 
     1300    destroy_stun_resolve(sess, PJ_FALSE); 
    12921301} 
    12931302 
     
    18491858        } 
    18501859 
    1851         /* Terminate any pending STUN resolution */ 
    1852         if (!pj_list_empty(&pjsua_var.stun_res)) { 
    1853             pjsua_stun_resolve *sess = pjsua_var.stun_res.next; 
    1854             while (sess != &pjsua_var.stun_res) { 
    1855                 pjsua_stun_resolve *next = sess->next; 
    1856                 destroy_stun_resolve(sess); 
    1857                 sess = next; 
    1858             } 
    1859         } 
    1860  
    18611860        /* Wait until all unregistrations are done (ticket #364) */ 
    18621861        /* First stage, get the maximum wait time */ 
     
    18991898 
    19001899        PJ_LOG(4,(THIS_FILE, "Destroying...")); 
     1900         
     1901        /* Terminate any pending STUN resolution */ 
     1902        if (!pj_list_empty(&pjsua_var.stun_res)) { 
     1903            pjsua_stun_resolve *sess = pjsua_var.stun_res.next; 
     1904            while (sess != &pjsua_var.stun_res) { 
     1905                pjsua_stun_resolve *next = sess->next; 
     1906                destroy_stun_resolve(sess, PJ_TRUE); 
     1907                sess = next; 
     1908            } 
     1909        } 
    19011910 
    19021911        /* Destroy media (to shutdown media endpoint, etc) */ 
Note: See TracChangeset for help on using the changeset viewer.