Commit 0d5c264e authored by Tristan Matthews's avatar Tristan Matthews

* #14340: daemon: check that transport selector was created before using.

Fixes abort() on failed registration.
parent aa88a421
......@@ -448,7 +448,7 @@ SipTransport::createUdpTransport(const std::string &interface, unsigned int port
return transport;
}
pjsip_tpselector *SipTransport::initTransportSelector(pjsip_transport *transport, pj_pool_t *tp_pool) const
pjsip_tpselector *SipTransport::createTransportSelector(pjsip_transport *transport, pj_pool_t *tp_pool) const
{
RETURN_IF_FAIL(transport != NULL, NULL, "Transport is not initialized");
pjsip_tpselector *tp = (pjsip_tpselector *) pj_pool_zalloc(tp_pool, sizeof(pjsip_tpselector));
......@@ -543,7 +543,7 @@ void SipTransport::findLocalAddressFromTransport(pjsip_transport *transport, pjs
// initialize a transport selector
// TODO Need to determine why we exclude TLS here...
// if (transportType == PJSIP_TRANSPORT_UDP and transport_)
pjsip_tpselector *tp_sel = initTransportSelector(transport, pool_);
pjsip_tpselector *tp_sel = createTransportSelector(transport, pool_);
RETURN_IF_NULL(tp_sel, "Could not initialize transport selector, using local address %s:%s", addr.c_str(), port.c_str());
pj_str_t localAddress = {0,0};
......
......@@ -104,7 +104,8 @@ class SipTransport {
*
* @return A pointer to the transport selector structure
*/
pjsip_tpselector *initTransportSelector(pjsip_transport *transport, pj_pool_t *tp_pool) const;
pjsip_tpselector *
createTransportSelector(pjsip_transport *transport, pj_pool_t *tp_pool) const;
/**
* This function unset the transport for a given account.
......
......@@ -279,7 +279,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
? account->getPublishedAddress()
: addrToUse;
pjsip_tpselector *tp = SIPVoIPLink::instance()->sipTransport.initTransportSelector(account->transport_, call->getMemoryPool());
pjsip_tpselector *tp_sel = SIPVoIPLink::instance()->sipTransport.createTransportSelector(account->transport_, call->getMemoryPool());
char tmp[PJSIP_MAX_URL_SIZE];
size_t length = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, sip_from_uri, tmp, PJSIP_MAX_URL_SIZE);
......@@ -350,7 +350,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
pjsip_inv_create_uas(dialog, rdata, call->getLocalSDP()->getLocalSdpSession(), 0, &call->inv);
if (pjsip_dlg_set_transport(dialog, tp) != PJ_SUCCESS) {
if (pjsip_dlg_set_transport(dialog, tp_sel) != PJ_SUCCESS) {
ERROR("Could not set transport for dialog");
delete call;
return PJ_FALSE;
......@@ -633,7 +633,11 @@ void SIPVoIPLink::sendRegister(Account *a)
if (pjsip_regc_register(regc, PJ_TRUE, &tdata) != PJ_SUCCESS)
throw VoipLinkException("Unable to initialize transaction data for account registration");
if (pjsip_regc_set_transport(regc, sipTransport.initTransportSelector(account->transport_, pool_)) != PJ_SUCCESS)
pjsip_tpselector *tp_sel = sipTransport.createTransportSelector(account->transport_, pool_);
if (tp_sel == NULL)
throw VoipLinkException("Unable to create transport selector");
if (pjsip_regc_set_transport(regc, tp_sel) != PJ_SUCCESS)
throw VoipLinkException("Unable to set transport");
// decrease transport's ref count, counter incrementation is managed when acquiring transport
......@@ -1304,9 +1308,9 @@ SIPVoIPLink::SIPStartCall(SIPCall *call)
return false;
}
pjsip_tpselector *tp = sipTransport.initTransportSelector(account->transport_, call->inv->pool);
pjsip_tpselector *tp_sel = sipTransport.createTransportSelector(account->transport_, call->inv->pool);
if (pjsip_dlg_set_transport(dialog, tp) != PJ_SUCCESS) {
if (pjsip_dlg_set_transport(dialog, tp_sel) != PJ_SUCCESS) {
ERROR("Unable to associate transport fir invite session dialog");
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment