Changeset 4773


Ignore:
Timestamp:
Feb 28, 2014 5:42:24 AM (5 years ago)
Author:
ming
Message:

Fixed #1699: Transport state callback to report transport shutdown events (Thanks to Johan Lantz for the discussion and preliminary patch).

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_transport.h

    r4275 r4773  
    13891389                                         to connection-oriented transports 
    13901390                                         such as TCP and TLS.               */ 
    1391     PJSIP_TP_STATE_DISCONNECTED     /**< Transport disconnected, applicable 
     1391    PJSIP_TP_STATE_DISCONNECTED,    /**< Transport disconnected, applicable 
    13921392                                         only to connection-oriented  
    13931393                                         transports such as TCP and TLS.    */ 
     1394    PJSIP_TP_STATE_SHUTDOWN,        /**< Transport shutdown, either 
     1395                                         due to TCP/TLS disconnect error 
     1396                                         from the network, or when shutdown 
     1397                                         is initiated by PJSIP itself.      */ 
     1398    PJSIP_TP_STATE_DESTROY,         /**< Transport destroy, when transport 
     1399                                         is about to be destroyed.          */ 
    13941400} pjsip_transport_state; 
    13951401 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport.c

    r4713 r4773  
    10921092    pjsip_tpmgr *mgr; 
    10931093    pj_status_t status; 
     1094    pjsip_tp_state_callback state_cb; 
    10941095 
    10951096    TRACE_((THIS_FILE, "Transport %s shutting down", tp->obj_name)); 
     
    11121113    if (tp->do_shutdown) 
    11131114        status = tp->do_shutdown(tp); 
    1114      
     1115 
     1116    /* Notify application of transport shutdown */ 
     1117    state_cb = pjsip_tpmgr_get_state_cb(tp->tpmgr); 
     1118    if (state_cb) { 
     1119        pjsip_transport_state_info state_info; 
     1120 
     1121        pj_bzero(&state_info, sizeof(state_info)); 
     1122        state_info.status = status; 
     1123        (*state_cb)(tp, PJSIP_TP_STATE_SHUTDOWN, &state_info); 
     1124    } 
     1125 
    11151126    if (status == PJ_SUCCESS) 
    11161127        tp->is_shutdown = PJ_TRUE; 
     
    11341145PJ_DEF(pj_status_t) pjsip_transport_destroy( pjsip_transport *tp) 
    11351146{ 
     1147    pjsip_tp_state_callback state_cb; 
     1148 
    11361149    /* Must have no user. */ 
    11371150    PJ_ASSERT_RETURN(pj_atomic_get(tp->ref_cnt) == 0, PJSIP_EBUSY); 
     1151 
     1152    /* Notify application of transport destroy */ 
     1153    state_cb = pjsip_tpmgr_get_state_cb(tp->tpmgr); 
     1154    if (state_cb) { 
     1155        pjsip_transport_state_info state_info; 
     1156 
     1157        pj_bzero(&state_info, sizeof(state_info)); 
     1158        (*state_cb)(tp, PJSIP_TP_STATE_DESTROY, &state_info); 
     1159    } 
    11381160 
    11391161    /* Destroy. */ 
Note: See TracChangeset for help on using the changeset viewer.