Changeset 2871 for pjproject


Ignore:
Timestamp:
Aug 12, 2009 10:28:47 PM (15 years ago)
Author:
bennylp
Message:

Ticket #933: Incoming OPTIONS may trigger assertion if it arrives when PJSUA-LIB is being shutdown (thanks Johan Lantz for the report)

  • destroy the media subsystem after busy_sleep(1000) in the shutdown sequence
  • also handle the case when OPTIONS arrives just when PJSUA-LIB is being initialized and media transport is not ready (in this case just reply OPTIONS without message body)
File:
1 edited

Legend:

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

    r2864 r2871  
    349349    } 
    350350 
    351     /* Get media socket info */ 
    352     pjmedia_transport_info_init(&tpinfo); 
    353     pjmedia_transport_get_info(pjsua_var.calls[0].med_tp, &tpinfo); 
    354  
    355     /* Add SDP body, using call0's RTP address */ 
    356     status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 1, 
    357                                       &tpinfo.sock_info, &sdp); 
    358     if (status == PJ_SUCCESS) { 
    359         pjsip_create_sdp_body(tdata->pool, sdp, &tdata->msg->body); 
     351    /* Get media socket info, make sure transport is ready */ 
     352    if (pjsua_var.calls[0].med_tp) { 
     353        pjmedia_transport_info_init(&tpinfo); 
     354        pjmedia_transport_get_info(pjsua_var.calls[0].med_tp, &tpinfo); 
     355 
     356        /* Add SDP body, using call0's RTP address */ 
     357        status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 1, 
     358                                          &tpinfo.sock_info, &sdp); 
     359        if (status == PJ_SUCCESS) { 
     360            pjsip_create_sdp_body(tdata->pool, sdp, &tdata->msg->body); 
     361        } 
    360362    } 
    361363 
     
    12491251    } 
    12501252 
    1251     /* Destroy media */ 
    1252     pjsua_media_subsys_destroy(); 
    1253  
    12541253    /* Destroy endpoint. */ 
    12551254    if (pjsua_var.endpt) { 
     
    12731272        PJ_LOG(4,(THIS_FILE, "Destroying...")); 
    12741273 
     1274        /* Terminate all calls again, just in case there's new call 
     1275         * picked up during busy_sleep() 
     1276         */ 
     1277        pjsua_call_hangup_all(); 
     1278 
     1279        /* Destroy media after all polling is done, as there may be 
     1280         * incoming request that needs handling (e.g. OPTIONS) 
     1281         */ 
     1282        pjsua_media_subsys_destroy(); 
     1283 
    12751284        /* Must destroy endpoint first before destroying pools in 
    12761285         * buddies or accounts, since shutting down transaction layer 
     
    12961305            } 
    12971306        } 
     1307    } else { 
     1308        /* Destroy media */ 
     1309        pjsua_media_subsys_destroy(); 
    12981310    } 
    12991311 
Note: See TracChangeset for help on using the changeset viewer.