Skip to content
Snippets Groups Projects
Commit 471061cf authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin
Browse files

call: hold mutex during merge

Change-Id: Ie1d1120957fe3e8bb38621b5ffa38f8d1e407b62
parent 7aeadc5f
No related branches found
No related tags found
No related merge requests found
...@@ -502,23 +502,18 @@ Call::subcallStateChanged(Call& subcall, ...@@ -502,23 +502,18 @@ Call::subcallStateChanged(Call& subcall,
} }
/// Replace current call data with ones from the given \a subcall. /// Replace current call data with ones from the given \a subcall.
/// /// Must be called while locked by subclass
void void
Call::merge(Call& subcall) Call::merge(Call& subcall)
{ {
JAMI_DBG("[call:%s] merge subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); JAMI_DBG("[call:%s] merge subcall %s", getCallId().c_str(), subcall.getCallId().c_str());
// Merge data // Merge data
{
std::lock(callMutex_, subcall.callMutex_);
std::lock_guard<std::recursive_mutex> lk1 {callMutex_, std::adopt_lock};
std::lock_guard<std::recursive_mutex> lk2 {subcall.callMutex_, std::adopt_lock};
pendingInMessages_ = std::move(subcall.pendingInMessages_); pendingInMessages_ = std::move(subcall.pendingInMessages_);
if (peerNumber_.empty()) if (peerNumber_.empty())
peerNumber_ = std::move(subcall.peerNumber_); peerNumber_ = std::move(subcall.peerNumber_);
peerDisplayName_ = std::move(subcall.peerDisplayName_); peerDisplayName_ = std::move(subcall.peerDisplayName_);
setState(subcall.getState(), subcall.getConnectionState()); setState(subcall.getState(), subcall.getConnectionState());
}
std::weak_ptr<Call> subCallWeak = subcall.shared_from_this(); std::weak_ptr<Call> subCallWeak = subcall.shared_from_this();
runOnMainThread([subCallWeak] { runOnMainThread([subCallWeak] {
......
...@@ -1349,9 +1349,12 @@ SIPCall::merge(Call& call) ...@@ -1349,9 +1349,12 @@ SIPCall::merge(Call& call)
// This static cast is safe as this method is private and overload Call::merge // This static cast is safe as this method is private and overload Call::merge
auto& subcall = static_cast<SIPCall&>(call); auto& subcall = static_cast<SIPCall&>(call);
std::lock(callMutex_, subcall.callMutex_);
std::lock_guard<std::recursive_mutex> lk1 {callMutex_, std::adopt_lock};
std::lock_guard<std::recursive_mutex> lk2 {subcall.callMutex_, std::adopt_lock};
inv = std::move(subcall.inv); inv = std::move(subcall.inv);
inv->mod_data[getSIPVoIPLink()->getModId()] = this; inv->mod_data[getSIPVoIPLink()->getModId()] = this;
setTransport(subcall.transport_); setTransport(std::move(subcall.transport_));
sdp_ = std::move(subcall.sdp_); sdp_ = std::move(subcall.sdp_);
peerHolding_ = subcall.peerHolding_; peerHolding_ = subcall.peerHolding_;
upnp_ = std::move(subcall.upnp_); upnp_ = std::move(subcall.upnp_);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment