Ignore:
Timestamp:
May 6, 2019 10:55:35 AM (5 years ago)
Author:
ming
Message:

Fixed #2196: Assertion due to unset sip error code when media initialization fails during incoming call

File:
1 edited

Legend:

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

    r5944 r5978  
    16871687 
    16881688on_return: 
    1689     if (status != PJ_SUCCESS && call_med->tp) { 
    1690         pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_NULL); 
    1691         pjmedia_transport_close(call_med->tp); 
    1692         call_med->tp = NULL; 
    1693     } 
    1694  
    1695     if (sip_err_code) 
    1696         *sip_err_code = err_code; 
     1689    if (status != PJ_SUCCESS) { 
     1690        if (call_med->tp) { 
     1691            pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_NULL); 
     1692            pjmedia_transport_close(call_med->tp); 
     1693            call_med->tp = NULL; 
     1694        } 
     1695 
     1696        if (err_code == 0) 
     1697            err_code = PJSIP_ERRNO_TO_SIP_STATUS(status); 
     1698 
     1699        if (sip_err_code) 
     1700            *sip_err_code = err_code; 
     1701    } 
    16971702 
    16981703    if (call_med->med_init_cb) { 
     
    17831788 
    17841789        if (status != PJ_SUCCESS) { 
     1790            if (sip_err_code) 
     1791                *sip_err_code = PJSIP_SC_INTERNAL_SERVER_ERROR; 
    17851792            call_med->tp_ready = status; 
    17861793            pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_NULL); 
     
    19932000 
    19942001    if (pjsua_get_state() != PJSUA_STATE_RUNNING) { 
    1995         if (sip_err_code) *sip_err_code = PJSIP_SC_SERVICE_UNAVAILABLE; 
     2002        if (sip_err_code) 
     2003            *sip_err_code = PJSIP_SC_SERVICE_UNAVAILABLE; 
    19962004        return PJ_EBUSY; 
    19972005    } 
     
    20022010 
    20032011        status = pj_mutex_create_simple(tmppool, NULL, &call->med_ch_mutex); 
    2004         if (status != PJ_SUCCESS) 
     2012        if (status != PJ_SUCCESS) { 
     2013            if (sip_err_code) 
     2014                *sip_err_code = PJSIP_SC_INTERNAL_SERVER_ERROR; 
    20052015            return status; 
     2016        } 
    20062017    } 
    20072018 
     
    20632074        if (maudcnt + mvidcnt == 0) { 
    20642075            /* Expecting audio or video in the offer */ 
    2065             if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 
     2076            if (sip_err_code) 
     2077                *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 
    20662078            status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE_HERE); 
    20672079            goto on_error; 
     
    21792191    if (call->med_prov_cnt == 0) { 
    21802192        /* Expecting at least one media */ 
    2181         if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 
     2193        if (sip_err_code) 
     2194            *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 
    21822195        status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE_HERE); 
    21832196        goto on_error; 
     
    22932306 
    22942307    status = media_channel_init_cb(call_id, NULL); 
    2295     if (status != PJ_SUCCESS && sip_err_code) 
    2296         *sip_err_code = call->med_ch_info.sip_err_code; 
     2308    if (status != PJ_SUCCESS && sip_err_code) { 
     2309        if (call->med_ch_info.sip_err_code) 
     2310            *sip_err_code = call->med_ch_info.sip_err_code; 
     2311        else 
     2312            *sip_err_code = PJSIP_ERRNO_TO_SIP_STATUS(status); 
     2313    } 
    22972314 
    22982315    pj_log_pop_indent(); 
     
    23042321        call->med_ch_mutex = NULL; 
    23052322    } 
     2323 
     2324    if (sip_err_code && *sip_err_code == 0) 
     2325        *sip_err_code = PJSIP_ERRNO_TO_SIP_STATUS(status); 
    23062326 
    23072327    pj_log_pop_indent(); 
     
    23312351    pj_status_t status; 
    23322352 
    2333     if (pjsua_get_state() != PJSUA_STATE_RUNNING) 
    2334         return PJ_EBUSY; 
     2353    if (pjsua_get_state() != PJSUA_STATE_RUNNING) { 
     2354        status = PJ_EBUSY; 
     2355        goto on_error; 
     2356    } 
    23352357 
    23362358#if 0 
     
    23972419                                           &origin, &sdp); 
    23982420    if (status != PJ_SUCCESS) 
    2399         return status; 
     2421        goto on_error; 
    24002422 
    24012423    /* Process each media line */ 
     
    25122534        default: 
    25132535            pj_assert(!"Invalid call_med media type"); 
    2514             return PJ_EBUG; 
     2536            status = PJ_EBUG; 
    25152537        } 
    25162538 
    25172539        if (status != PJ_SUCCESS) 
    2518             return status; 
     2540            goto on_error; 
    25192541 
    25202542        /* Add ssrc and cname attribute */ 
     
    25302552        if (status != PJ_SUCCESS) { 
    25312553            if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE; 
    2532             return status; 
     2554            goto on_error; 
    25332555        } 
    25342556 
     
    26742696    *p_sdp = sdp; 
    26752697    return PJ_SUCCESS; 
     2698 
     2699on_error: 
     2700    if (sip_err_code && *sip_err_code == 0) 
     2701        *sip_err_code = PJSIP_SC_INTERNAL_SERVER_ERROR; 
     2702 
     2703    return status; 
    26762704} 
    26772705 
Note: See TracChangeset for help on using the changeset viewer.