From 8e777d50a63038a73cb2e56d24698aa9bb416e57 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 May 2017 05:34:25 +0100 Subject: only remove AsyncCommandManager thread when last instance is deleted --- .../Shared/Api/Implementation/AsyncCommandManager.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 2a31efd..5e7a724 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private static Thread cmdHandlerThread; private static int cmdHandlerThreadCycleSleepms; - + private static int numInstances; /// /// Lock for reading/writing static components of AsyncCommandManager. /// @@ -172,6 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!m_XmlRequest.ContainsKey(m_ScriptEngine)) m_XmlRequest[m_ScriptEngine] = new XmlRequest(this); + numInstances++; StartThread(); } } @@ -199,12 +200,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Shut down thread try { - if (cmdHandlerThread != null) + lock (staticLock) { - if (cmdHandlerThread.IsAlive == true) + numInstances--; + if(numInstances > 0) + return; + if (cmdHandlerThread != null) { - cmdHandlerThread.Abort(); + if (cmdHandlerThread.IsAlive == true) + { + cmdHandlerThread.Abort(); //cmdHandlerThread.Join(); + } } } } -- cgit v1.1