Changeset 4653 for pjproject


Ignore:
Timestamp:
Nov 19, 2013 10:18:17 AM (10 years ago)
Author:
bennylp
Message:

Fixed #1712: Must not send BYE before ACK is received

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h

    r4583 r4653  
    394394    pj_bool_t            cancelling;                /**< CANCEL requested   */ 
    395395    pj_bool_t            pending_cancel;            /**< Wait to send CANCEL*/ 
     396    pjsip_tx_data       *pending_bye;               /**< BYE to send later  */ 
    396397    pjsip_status_code    cause;                     /**< Disconnect cause.  */ 
    397398    pj_str_t             cause_text;                /**< Cause text.        */ 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r4583 r4653  
    264264            inv->invite_req = NULL; 
    265265        } 
     266        if (inv->pending_bye) { 
     267            pjsip_tx_data_dec_ref(inv->pending_bye); 
     268            inv->pending_bye = NULL; 
     269        } 
    266270        pjsip_100rel_end_session(inv); 
    267271        pjsip_timer_end_session(inv); 
     
    356360} 
    357361 
     362/* Process pending disconnection 
     363 *  http://trac.pjsip.org/repos/ticket/1712 
     364 */ 
     365static void inv_perform_pending_bye(pjsip_inv_session *inv) 
     366{ 
     367    if (inv->pending_bye) { 
     368        pjsip_tx_data *bye = inv->pending_bye; 
     369        pj_status_t status; 
     370 
     371        PJ_LOG(4,(inv->dlg->obj_name, "Sending pending BYE")); 
     372 
     373        inv->pending_bye = NULL; 
     374        status = pjsip_inv_send_msg(inv, bye); 
     375 
     376        if (status != PJ_SUCCESS) { 
     377            PJ_PERROR(1,(inv->dlg->obj_name, status, 
     378                         "Failed sending pending BYE")); 
     379        } 
     380    } 
     381} 
    358382 
    359383/* 
     
    529553            PJSIP_EVENT_INIT_RX_MSG(event, rdata); 
    530554            inv_set_state(inv, PJSIP_INV_STATE_CONFIRMED, &event); 
     555 
     556            /* Send pending BYE if any: 
     557             *   http://trac.pjsip.org/repos/ticket/1712 
     558             * Do this after setting the state to CONFIRMED, so that we 
     559             * have consistent CONFIRMED state between caller and callee. 
     560             */ 
     561            if (inv->pending_bye) 
     562                inv_perform_pending_bye(inv); 
    531563        } 
    532564    } 
     
    28902922        } 
    28912923 
     2924        /* Don't send BYE before ACK is received 
     2925         * http://trac.pjsip.org/repos/ticket/1712 
     2926         */ 
     2927        if (tdata->msg->line.req.method.id == PJSIP_BYE_METHOD && 
     2928            inv->role == PJSIP_ROLE_UAS && 
     2929            inv->state == PJSIP_INV_STATE_CONNECTING) 
     2930        { 
     2931            if (inv->pending_bye) 
     2932                pjsip_tx_data_dec_ref(inv->pending_bye); 
     2933 
     2934            inv->pending_bye = tdata; 
     2935            PJ_LOG(4, (inv->obj_name, "Delaying BYE request until " 
     2936                       "ACK is received")); 
     2937            pjsip_dlg_dec_lock(inv->dlg); 
     2938            goto on_return; 
     2939        } 
     2940 
    28922941        /* Associate our data in outgoing invite transaction */ 
    28932942        tsx_inv_data = PJ_POOL_ZALLOC_T(inv->pool, struct tsx_inv_data); 
     
    29252974 
    29262975    /* Done */ 
     2976on_return: 
    29272977    pj_log_pop_indent(); 
    29282978    return PJ_SUCCESS; 
     
    40924142 
    40934143                inv_set_state(inv, PJSIP_INV_STATE_CONFIRMED, e); 
     4144 
     4145                /* Send pending BYE if any: 
     4146                 *   http://trac.pjsip.org/repos/ticket/1712 
     4147                 * Do this after setting the state to CONFIRMED, so that we 
     4148                 * have consistent CONFIRMED state between caller and callee. 
     4149                 */ 
     4150                if (inv->pending_bye) 
     4151                    inv_perform_pending_bye(inv); 
     4152 
    40944153            } 
    40954154            break; 
Note: See TracChangeset for help on using the changeset viewer.