diff --git a/Pod/Classes/VSLEndpoint.m b/Pod/Classes/VSLEndpoint.m index 84ca3bf5..ae29d2b4 100644 --- a/Pod/Classes/VSLEndpoint.m +++ b/Pod/Classes/VSLEndpoint.m @@ -511,10 +511,10 @@ static void onRegState2(pjsua_acc_id acc_id, pjsua_reg_info *info) { DDLogVerbose(@"onRegState2"); struct pjsip_regc_cbparam *rp = info->cbparam; + releaseStoredTransport(); if (rp->code/100 == 2 && rp->expiration > 0 && rp->contact_cnt > 0) { - // TCP tranport already saved in onRegStarted - } else { - releaseStoredTransport(); + the_transport = rp->rdata->tp_info.transport; + pjsip_transport_add_ref(the_transport); } VSLAccount *account = [[VSLEndpoint sharedEndpoint] lookupAccount:acc_id]; @@ -528,6 +528,8 @@ static void onTransportState(pjsip_transport *tp, pjsip_transport_state state, c if (state == PJSIP_TP_STATE_DISCONNECTED && the_transport == tp) { releaseStoredTransport(); } + the_transport = tp; + pjsip_transport_add_ref(tp); } static void onIncomingCall(pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata) { @@ -571,9 +573,9 @@ static void releaseStoredTransport() { * @return YES if succesfull */ - (BOOL)shutdownTransport { - pj_status_t status; if (the_transport) { + pj_status_t status; status = pjsip_transport_shutdown(the_transport); DDLogInfo(@"Shuting down transport"); if (status != PJ_SUCCESS) {