only remove AsyncCommandManager thread when last instance is deleted

0.9.0-post-fixes
UbitUmarov 2017-05-23 05:34:25 +01:00
parent e69057a1b6
commit 8e777d50a6
1 changed files with 11 additions and 4 deletions

View File

@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private static Thread cmdHandlerThread; private static Thread cmdHandlerThread;
private static int cmdHandlerThreadCycleSleepms; private static int cmdHandlerThreadCycleSleepms;
private static int numInstances;
/// <summary> /// <summary>
/// Lock for reading/writing static components of AsyncCommandManager. /// Lock for reading/writing static components of AsyncCommandManager.
/// </summary> /// </summary>
@ -172,6 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_XmlRequest.ContainsKey(m_ScriptEngine)) if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
m_XmlRequest[m_ScriptEngine] = new XmlRequest(this); m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
numInstances++;
StartThread(); StartThread();
} }
} }
@ -199,6 +200,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Shut down thread // Shut down thread
try try
{ {
lock (staticLock)
{
numInstances--;
if(numInstances > 0)
return;
if (cmdHandlerThread != null) if (cmdHandlerThread != null)
{ {
if (cmdHandlerThread.IsAlive == true) if (cmdHandlerThread.IsAlive == true)
@ -208,6 +214,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
} }
}
catch catch
{ {
} }