summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-20 16:51:49 +0100
committerMattes D <github@xoft.cz>2015-03-20 16:51:49 +0100
commit0f45d1fbe20adbc022bcab6e0f76031f35a2e81d (patch)
tree6a6b14eaf98ce1b2008d5cbd22436e2da5ad3dee
parentMerge pull request #1822 from mc-server/ResettableLuaCallback (diff)
downloadcuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.tar
cuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.tar.gz
cuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.tar.bz2
cuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.tar.lz
cuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.tar.xz
cuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.tar.zst
cuberite-0f45d1fbe20adbc022bcab6e0f76031f35a2e81d.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/PluginLua.cpp18
-rw-r--r--src/Bindings/PluginLua.h5
2 files changed, 13 insertions, 10 deletions
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index d133c091a..0a2a8411d 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -63,12 +63,17 @@ void cPluginLua::Close(void)
return;
}
- // Notify and remove all m_Resettables:
- for (auto resettable: m_Resettables)
+ // Notify and remove all m_Resettables (unlock the m_CriticalSection while resetting them):
+ cResettablePtrs resettables;
+ std::swap(m_Resettables, resettables);
{
- resettable->Reset();
- }
- m_Resettables.clear();
+ cCSUnlock Unlock(Lock);
+ for (auto resettable: resettables)
+ {
+ resettable->Reset();
+ }
+ m_Resettables.clear();
+ } // cCSUnlock (m_CriticalSection)
// Release all the references in the hook map:
for (cHookMap::iterator itrH = m_HookMap.begin(), endH = m_HookMap.end(); itrH != endH; ++itrH)
@@ -1853,8 +1858,7 @@ void cPluginLua::CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int
// cPluginLua::cResettable:
cPluginLua::cResettable::cResettable(cPluginLua & a_Plugin):
- m_Plugin(&a_Plugin),
- m_CSPlugin(a_Plugin.m_CriticalSection)
+ m_Plugin(&a_Plugin)
{
}
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index e358693bc..c14b02687 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -84,9 +84,8 @@ public:
Protected against multithreaded access by m_CSPlugin. */
cPluginLua * m_Plugin;
- /** The mutex protecting m_Plugin against multithreaded access.
- Actually points to m_Plugin's internal m_CriticalSection in order to prevent deadlocks. */
- cCriticalSection & m_CSPlugin;
+ /** The mutex protecting m_Plugin against multithreaded access. */
+ cCriticalSection m_CSPlugin;
};
typedef SharedPtr<cResettable> cResettablePtr;