aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2019-09-18 18:48:23 +0200
committerSmallJoker <mk939@ymail.com>2019-09-18 18:48:41 +0200
commit4271889ef832806e7bd57e552f15b24fdf162c8d (patch)
treec6926d66803dd27e1da074f5cf28dc0361521302 /src
parent94a5df795c6d591042d8c29dc4548afdd1074190 (diff)
downloadminetest-4271889ef832806e7bd57e552f15b24fdf162c8d.tar.gz
minetest-4271889ef832806e7bd57e552f15b24fdf162c8d.tar.bz2
minetest-4271889ef832806e7bd57e552f15b24fdf162c8d.zip
Settings: Prevent mutex deadlock in remove() (#7803)
Diffstat (limited to 'src')
-rw-r--r--src/settings.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 876c63e7b..c1fe41fa3 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -908,17 +908,20 @@ bool Settings::setNoiseParams(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);
if (it != m_settings.end()) {
delete it->second.group;
m_settings.erase(it);
+ m_mutex.unlock();
doCallbacks(name);
return true;
}
+ m_mutex.unlock();
return false;
}