From 227d2e2b616ad52331b387f2dbf3392583f194f6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 10 Dec 2014 00:04:10 +0000 Subject: [PATCH] Avoid a possible race condition where the XEngine script compile thread could complete but see OnRezScript() insert a new job and complete before it set m_CurrentCompile = null If the above happened, it would mean the new script would not compile until some script was added for compilation. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 7ff82e6bec..ccd5d990fd 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1101,7 +1101,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine // due to a race condition // lock (m_CompileQueue) + { m_CurrentCompile = null; + + // This is to avoid a situation where the m_CompileQueue while loop above could complete but + // OnRezScript() place a new script on the queue and check m_CurrentCompile = null before we hit + // this section. + if (m_CompileQueue.Count > 0) + m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); + } } return null;