Ignore:
Timestamp:
Feb 20, 2017 1:16:58 AM (4 years ago)
Author:
ming
Message:

Closed #1995: Add API pjsip_transport_shutdown2() to immediately disconnect a transport

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_transport.c

    r5400 r5556  
    11641164PJ_DEF(pj_status_t) pjsip_transport_shutdown(pjsip_transport *tp) 
    11651165{ 
     1166    return pjsip_transport_shutdown2(tp, PJ_FALSE); 
     1167} 
     1168 
     1169 
     1170/* 
     1171 * Start shutdown procedure for this transport.  
     1172 */ 
     1173PJ_DEF(pj_status_t) pjsip_transport_shutdown2(pjsip_transport *tp, 
     1174                                              pj_bool_t force) 
     1175{ 
    11661176    pjsip_tpmgr *mgr; 
    11671177    pj_status_t status; 
    11681178    pjsip_tp_state_callback state_cb; 
    11691179 
    1170     TRACE_((THIS_FILE, "Transport %s shutting down", tp->obj_name)); 
     1180    PJ_LOG(4, (THIS_FILE, "Transport %s shutting down, force=%d", 
     1181                          tp->obj_name, force)); 
    11711182 
    11721183    pj_lock_acquire(tp->lock); 
     
    11881199        status = tp->do_shutdown(tp); 
    11891200 
     1201    if (status == PJ_SUCCESS) 
     1202        tp->is_shutdown = PJ_TRUE; 
     1203 
    11901204    /* Notify application of transport shutdown */ 
    11911205    state_cb = pjsip_tpmgr_get_state_cb(tp->tpmgr); 
     
    11941208 
    11951209        pj_bzero(&state_info, sizeof(state_info)); 
    1196         state_info.status = status; 
    1197         (*state_cb)(tp, PJSIP_TP_STATE_SHUTDOWN, &state_info); 
    1198     } 
    1199  
    1200     if (status == PJ_SUCCESS) 
    1201         tp->is_shutdown = PJ_TRUE; 
     1210        state_info.status = PJ_ECANCELLED; 
     1211        (*state_cb)(tp, (force? PJSIP_TP_STATE_DISCONNECTED: 
     1212                    PJSIP_TP_STATE_SHUTDOWN), &state_info); 
     1213    } 
    12021214 
    12031215    /* If transport reference count is zero, start timer count-down */ 
Note: See TracChangeset for help on using the changeset viewer.