1
0

cPluginLua:cResettable no longer shares CS with plugin.

This fixes locking the resettable while the plugin is already gone. Hopefully no deadlocks.
This commit is contained in:
Mattes D 2015-03-20 16:51:49 +01:00
parent 8a43da0723
commit 0f45d1fbe2
2 changed files with 13 additions and 10 deletions

View File

@ -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)
{
}

View File

@ -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;