Skip to content
Snippets Groups Projects
Commit 2c6b0379 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

sip: remove "add-if-not-found" idiom which not wanted

This patch changes SipTransportBroker::findTransport() method
by removing the possibility to map a pjsip transport if not
found in the mapping.

Rationale:
This idiom breaks the expected behavior of the method and let unknown
transports be handled by application.
Alien transports have not to be handled by us.
Now an handled transport is shutdown when SipTransport is destroyed,
and the constructor throw an exception if this transport is given
again... so impossible to "re-use" a shutdown'ed transport.

Refs #64903

Change-Id: Ib06f8f9d567f1bc84bfe4764f4f6c1252f7dc9ec
parent 35674a41
No related branches found
No related tags found
No related merge requests found
......@@ -243,22 +243,16 @@ SipTransportBroker::transportStateChanged(pjsip_transport* tp, pjsip_transport_s
std::shared_ptr<SipTransport>
SipTransportBroker::findTransport(pjsip_transport* t)
{
if (!t)
return nullptr;
{
if (t) {
std::lock_guard<std::mutex> lock(transportMapMutex_);
auto i = transports_.find(t);
if (i == transports_.end()) {
auto ret = std::make_shared<SipTransport>(t);
transports_[t] = ret;
return ret;
auto key = transports_.find(t);
if (key != transports_.end())
return key->second.lock();
}
else if (auto spt = i->second.lock())
return spt;
else
return nullptr;
}
}
void
SipTransportBroker::shutdown()
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment