From 772c5b7db030eb95da8852d711323244cfa91ab4 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Thu, 25 May 2017 06:05:02 +0100
Subject: move assetsconnector threads to whatchdog; Abort all alive threads
known to watchdog before exit
---
OpenSim/Framework/Monitoring/Watchdog.cs | 24 ++++++++++++++++++++++
OpenSim/Framework/Monitoring/WorkManager.cs | 1 +
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 3 ++-
.../Api/Implementation/AsyncCommandManager.cs | 1 +
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 1 +
OpenSim/Server/Base/ServicesServerBase.cs | 2 +-
6 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index 9cc61ee..8a4894e 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -180,6 +180,30 @@ namespace OpenSim.Framework.Monitoring
m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
}
+ public static void Stop()
+ {
+ if(m_threads == null)
+ return;
+
+ lock(m_threads)
+ {
+ m_enabled = false;
+ if(m_watchdogTimer != null)
+ {
+ m_watchdogTimer.Dispose();
+ m_watchdogTimer = null;
+ }
+
+ foreach(ThreadWatchdogInfo twi in m_threads.Values)
+ {
+ Thread t = twi.Thread;
+ if(t.IsAlive)
+ t.Abort();
+ }
+ m_threads.Clear();
+ }
+ }
+
///
/// Add a thread to the watchdog tracker.
///
diff --git a/OpenSim/Framework/Monitoring/WorkManager.cs b/OpenSim/Framework/Monitoring/WorkManager.cs
index a3e0390..9d52f71 100644
--- a/OpenSim/Framework/Monitoring/WorkManager.cs
+++ b/OpenSim/Framework/Monitoring/WorkManager.cs
@@ -85,6 +85,7 @@ namespace OpenSim.Framework.Monitoring
public static void Stop()
{
JobEngine.Stop();
+ Watchdog.Stop();
}
///
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index bc68681..81dd357 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -119,9 +119,10 @@ namespace OpenSim.Framework.Servers
Thread.Sleep(1000);
RemovePIDFile();
+
m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
- if (!SuppressExit)
+ if (!SuppressExit)
Environment.Exit(0);
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 5f57f39..1688aa6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -231,6 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Watchdog.UpdateThread();
}
+ catch ( System.Threading.ThreadAbortException) { }
catch (Exception e)
{
m_log.Error("[ASYNC COMMAND MANAGER]: Exception in command handler pass: ", e);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 2e39033..c1abba2 100755
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1079,6 +1079,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
"[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name);
}
}
+ catch (System.Threading.ThreadAbortException) { }
catch (Exception e)
{
m_log.Error(
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 2185727..176e876 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -252,7 +252,7 @@ namespace OpenSim.Server.Base
MemoryWatchdog.Enabled = false;
Watchdog.Enabled = false;
-
+ WorkManager.Stop();
RemovePIDFile();
return 0;
--
cgit v1.1