From f3eb73926e1602f855f2c7fceb040b07f7265f3b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 May 2017 04:05:31 +0100 Subject: stop a few more threads on exit --- .../Api/Implementation/AsyncCommandManager.cs | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 6a39bb9..2a31efd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -197,20 +197,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ~AsyncCommandManager() { // Shut down thread -// try -// { -// if (cmdHandlerThread != null) -// { -// if (cmdHandlerThread.IsAlive == true) -// { -// cmdHandlerThread.Abort(); -// //cmdHandlerThread.Join(); -// } -// } -// } -// catch -// { -// } + try + { + if (cmdHandlerThread != null) + { + if (cmdHandlerThread.IsAlive == true) + { + cmdHandlerThread.Abort(); + //cmdHandlerThread.Join(); + } + } + } + catch + { + } } /// @@ -387,8 +387,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - - public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) { List data = new List(); -- cgit v1.1 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/AsyncCommandManager.cs') 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 From d5e8e116d4b4e02e338d95ae084c9d6270139dcb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 May 2017 05:41:04 +0100 Subject: protect AsyncCommandManager thread from fails on the several things it checks --- .../Shared/Api/Implementation/AsyncCommandManager.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 5e7a724..cefd39e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -247,24 +247,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (staticLock) { // Check HttpRequests - m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); + try { m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); } catch {} // Check XMLRPCRequests - m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); + try { m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); } catch {} foreach (IScriptEngine s in m_ScriptEngines) { // Check Listeners - m_Listener[s].CheckListeners(); + try { m_Listener[s].CheckListeners(); } catch {} + // Check timers - m_Timer[s].CheckTimerEvents(); + try { m_Timer[s].CheckTimerEvents(); } catch {} // Check Sensors - m_SensorRepeat[s].CheckSenseRepeaterEvents(); + try { m_SensorRepeat[s].CheckSenseRepeaterEvents(); } catch {} // Check dataserver - m_Dataserver[s].ExpireRequests(); + try { m_Dataserver[s].ExpireRequests(); } catch {} } } } -- cgit v1.1 From e1aa591815f451f4fcf7eb49065d8e300141d9bf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 May 2017 05:59:14 +0100 Subject: allow new thread creation if it was aborted on AsyncCommandManager --- .../Shared/Api/Implementation/AsyncCommandManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index cefd39e..4714275 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -182,9 +182,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (cmdHandlerThread == null) { // Start the thread that will be doing the work - cmdHandlerThread - = WorkManager.StartThread( + lock (staticLock) + { + cmdHandlerThread = WorkManager.StartThread( CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true); + } } } @@ -210,7 +212,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (cmdHandlerThread.IsAlive == true) { cmdHandlerThread.Abort(); - //cmdHandlerThread.Join(); + //cmdHandlerThread.Join(); + cmdHandlerThread = null; } } } -- cgit v1.1 From 3c97bb1e6fe5a850f35929da58321655331ebae1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 May 2017 06:03:51 +0100 Subject: fix lock position removing a not necessary function --- .../Shared/Api/Implementation/AsyncCommandManager.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 4714275..eb6455a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -173,16 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_XmlRequest[m_ScriptEngine] = new XmlRequest(this); numInstances++; - StartThread(); - } - } - - private static void StartThread() - { - if (cmdHandlerThread == null) - { - // Start the thread that will be doing the work - lock (staticLock) + if (cmdHandlerThread == null) { cmdHandlerThread = WorkManager.StartThread( CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true); -- cgit v1.1