Skip to content
Snippets Groups Projects
Commit 11d4d914 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

siptransportbroker: avoid deadlock when stopping daemon

SipTransportBroker::shutdown triggers pjsip_transport_shutdown
that can call transportStateChanged synchronously. In this case,
transportMapMutex_ is locked, causing a deadlock on a single thread.
We don't care about the transport's map at this point as we are
destroying the transportbroker, so we can just ignore the state
changed here.

Change-Id: I180ff1807fe87d1c48d72851f17e94ae2f892823
parent c7bb74a1
No related branches found
No related tags found
No related merge requests found
......@@ -206,7 +206,7 @@ SipTransportBroker::transportStateChanged(pjsip_transport* tp,
std::shared_ptr<SipTransport> sipTransport;
{
if (!isDestroying_) {
std::lock_guard<std::mutex> lock(transportMapMutex_);
auto key = transports_.find(tp);
if (key == transports_.end())
......@@ -269,6 +269,7 @@ void
SipTransportBroker::shutdown()
{
std::unique_lock<std::mutex> lock(transportMapMutex_);
isDestroying_ = true;
for (auto& t : transports_) {
if (auto transport = t.second.lock()) {
pjsip_transport_shutdown(transport->get());
......
......@@ -197,6 +197,7 @@ private:
std::map<IpAddr, pjsip_transport*> udpTransports_;
pjsip_endpoint* endpt_;
std::atomic_bool isDestroying_ {false};
};
} // namespace jami
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment