call: avoid potential deadlock

Do not emit CallSignal::StateChange while locked. Because if the
client uses any method that lock callMutex_ it will be a deadlock.

Change-Id: I49aa7cb4ee60b23ef069751a7c1abbf4c9fcec95
This commit is contained in:
Sébastien Blin
2021-09-10 13:42:33 -04:00
parent d75289477f
commit e31d1d723e

View File

@ -240,7 +240,7 @@ Call::validStateTransition(CallState newState)
bool
Call::setState(CallState call_state, ConnectionState cnx_state, signed code)
{
std::lock_guard<std::recursive_mutex> lock(callMutex_);
std::unique_lock<std::recursive_mutex> lock(callMutex_);
JAMI_DBG("[call:%s] state change %u/%u, cnx %u/%u, code %d",
id_.c_str(),
(unsigned) callState_,
@ -275,6 +275,7 @@ Call::setState(CallState call_state, ConnectionState cnx_state, signed code)
id_.c_str(),
new_client_state.c_str(),
code);
lock.unlock();
emitSignal<DRing::CallSignal::StateChange>(id_, new_client_state, code);
}
}