MT#59962 AmSession: avoid dead-lock in `setStopped()`

In case the override func of virtual `onStop()`
anyhow reaches the AmSession again, and falls into
the scope where the same mutex lock is used (snapshot_lock)
this will be a dead-lock.

Hence preserve such, but manually managing the lock,
and release it, when calling the virtual func.

Change-Id: I7c7c4700767dd3aed1c482559be02e3a97cca407
mr26.1.1
Donat Zenichev 2 months ago
parent c1d75be834
commit 1ec74572da

@ -531,15 +531,20 @@ void AmSession::finalize()
}
void AmSession::setStopped(bool wakeup) {
/* make snapshot safe */
lock_guard<AmMutex> lock(snapshot_lock);
/* explicit lock management, for the case when onStop()'s override
* anyhow reaches the same mutex lock in similar scope.
*/
snapshot_lock.lock();
if (!sess_stopped.get()) {
sess_stopped.set(true);
snapshot_lock.unlock(); /* release now for dead-lock safety */
onStop();
}
snapshot_lock.lock();
if (wakeup)
AmSessionContainer::instance()->postEvent(getLocalTag(), new AmEvent(E_TERMINATE_LEG));
snapshot_lock.unlock();
}
string AmSession::getAppParam(const string& param_name) const

Loading…
Cancel
Save