mirror of
https://github.com/minetest/minetest.git
synced 2024-12-02 12:33:45 +01:00
Settings: Prevent mutex deadlock in remove() (#7803)
This commit is contained in:
parent
94a5df795c
commit
4271889ef8
@ -908,17 +908,20 @@ bool Settings::setNoiseParams(const std::string &name,
|
|||||||
|
|
||||||
bool Settings::remove(const std::string &name)
|
bool Settings::remove(const std::string &name)
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_mutex);
|
// Lock as short as possible, unlock before doCallbacks()
|
||||||
|
m_mutex.lock();
|
||||||
|
|
||||||
SettingEntries::iterator it = m_settings.find(name);
|
SettingEntries::iterator it = m_settings.find(name);
|
||||||
if (it != m_settings.end()) {
|
if (it != m_settings.end()) {
|
||||||
delete it->second.group;
|
delete it->second.group;
|
||||||
m_settings.erase(it);
|
m_settings.erase(it);
|
||||||
|
m_mutex.unlock();
|
||||||
|
|
||||||
doCallbacks(name);
|
doCallbacks(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_mutex.unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user