Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure MT with 1 thread behaves identical to ST

  • Loading branch information...
commit 6d6a367b04f93546528677acb3381d4e0cb44977 1 parent 946eaf8
@zerver zerver authored
View
9 rts/Lua/LuaHandle.cpp
@@ -224,7 +224,8 @@ bool CLuaHandle::LoadCode(lua_State *L, const string& code, const string& debug)
void CLuaHandle::CheckStack()
{
- // FIXME WTF this has NOTHING to do with the stack! esp. it should be called AFTER the stack was checked
+ // although Execute* have nothing to do with the stack, this happens to be a good place for it,
+ // and these calls must be located before the actual stack check to avoid a deadlock
ExecuteCallsFromSynced(false);
ExecuteUnitEventBatch();
ExecuteFeatEventBatch();
@@ -234,7 +235,7 @@ void CLuaHandle::CheckStack()
ExecuteLogEventBatch();
SELECT_LUA_STATE();
- GML_DRCMUTEX_LOCK(lua); // CheckStack - avoid bogus errors due to concurrency
+ GML_DRCMUTEX_LOCK(lua); // CheckStack
const int top = lua_gettop(L);
if (top != 0) {
@@ -248,7 +249,7 @@ void CLuaHandle::RecvFromSynced(lua_State *srcState, int args) {
SELECT_UNSYNCED_LUA_STATE();
#if ((LUA_MT_OPT & LUA_STATE) && (LUA_MT_OPT & LUA_MUTEX))
- if (!SingleState() && srcState != L) { // Sim thread sends to unsynced --> delay it
+ if (/*GML::Enabled() &&*/ !SingleState() && srcState != L) { // Sim thread sends to unsynced --> delay it
DelayRecvFromSynced(srcState, args);
return;
}
@@ -323,7 +324,7 @@ int CLuaHandle::SendToUnsynced(lua_State* L)
bool CLuaHandle::ExecuteCallsFromSynced(bool forced) {
#if (LUA_MT_OPT & LUA_MUTEX)
- if ((SingleState() && (this != luaUI)) || (forced && !PurgeCallsFromSyncedBatch()))
+ if (!GML::Enabled() || (SingleState() && (this != luaUI)) || (forced && !PurgeCallsFromSyncedBatch()))
#endif
return false;
View
2  rts/Lua/LuaHandleSynced.cpp
@@ -758,7 +758,7 @@ void CLuaHandleSynced::RecvFromSynced(lua_State *srcState, int args)
SELECT_UNSYNCED_LUA_STATE();
#if ((LUA_MT_OPT & LUA_STATE) && (LUA_MT_OPT & LUA_MUTEX))
- if (!SingleState() && srcState != L) { // Sim thread sends to unsynced --> delay it
+ if (/*GML::Enabled() &&*/ !SingleState() && srcState != L) { // Sim thread sends to unsynced --> delay it
DelayRecvFromSynced(srcState, args);
return;
}
View
6 rts/Lua/LuaUI.cpp
@@ -830,7 +830,7 @@ bool CLuaUI::HasUnsyncedXCall(lua_State* srcState, const string& funcName)
{
SELECT_LUA_STATE();
#if (LUA_MT_OPT & LUA_MUTEX)
- if (srcState != L && SingleState()) {
+ if (GML::Enabled() && srcState != L && SingleState()) {
GML_STDMUTEX_LOCK(xcall); // HasUnsyncedXCall
return unsyncedXCalls.find(funcName) != unsyncedXCalls.end();
@@ -847,7 +847,7 @@ bool CLuaUI::HasUnsyncedXCall(lua_State* srcState, const string& funcName)
int CLuaUI::UnsyncedXCall(lua_State* srcState, const string& funcName)
{
#if (LUA_MT_OPT & LUA_MUTEX)
- {
+ if (GML::Enabled()) {
SELECT_UNSYNCED_LUA_STATE();
if (srcState != L) {
DelayDataDump ddmp;
@@ -950,7 +950,7 @@ int CLuaUI::SetShockFrontFactors(lua_State* L)
int CLuaUI::UpdateUnsyncedXCalls(lua_State* L)
{
#if (LUA_MT_OPT & LUA_MUTEX)
- if (!SingleState() || L != L_Sim)
+ if (!GML::Enabled() || !SingleState() || L != L_Sim)
#endif
return 0;
Please sign in to comment.
Something went wrong with that request. Please try again.