diff options
author | John Hurliman | 2009-10-22 12:33:23 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-22 12:33:23 -0700 |
commit | b2ed348aa2746fbf034b713d006e40366c479d5a (patch) | |
tree | 26c114e88f54e64e1fdf17dcc7de1e54165db2bc /OpenSim/Region/OptionalModules | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.zip opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.gz opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.bz2 opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.xz |
Implemented a Watchdog class. Do not manually create Thread objects anymore, use Watchdog.StartThread(). While your thread is running call Watchdog.UpdateThread(). When it is shutting down call Watchdog.RemoveThread(). Most of the threads in OpenSim have been updated
Diffstat (limited to '')
3 files changed, 16 insertions, 11 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index df03b8d..4b0d01a 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -67,9 +67,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
67 | { | 67 | { |
68 | m_client = client; | 68 | m_client = client; |
69 | m_scene = scene; | 69 | m_scene = scene; |
70 | 70 | ||
71 | Thread loopThread = new Thread(InternalLoop); | 71 | Watchdog.StartThread(InternalLoop, "IRCClientView", ThreadPriority.Normal, false); |
72 | loopThread.Start(); | ||
73 | } | 72 | } |
74 | 73 | ||
75 | private void SendServerCommand(string command) | 74 | private void SendServerCommand(string command) |
@@ -102,7 +101,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
102 | { | 101 | { |
103 | try | 102 | try |
104 | { | 103 | { |
105 | string strbuf = ""; | 104 | string strbuf = String.Empty; |
106 | 105 | ||
107 | while (m_connected && m_client.Connected) | 106 | while (m_connected && m_client.Connected) |
108 | { | 107 | { |
@@ -140,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
140 | } | 139 | } |
141 | 140 | ||
142 | Thread.Sleep(0); | 141 | Thread.Sleep(0); |
142 | Watchdog.UpdateThread(); | ||
143 | } | 143 | } |
144 | } | 144 | } |
145 | catch (IOException) | 145 | catch (IOException) |
@@ -156,6 +156,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
156 | 156 | ||
157 | m_log.Warn("[IRCd] Disconnected client."); | 157 | m_log.Warn("[IRCd] Disconnected client."); |
158 | } | 158 | } |
159 | |||
160 | Watchdog.RemoveThread(); | ||
159 | } | 161 | } |
160 | 162 | ||
161 | private void ProcessInMessage(string message, string command) | 163 | private void ProcessInMessage(string message, string command) |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs index 91ce9f1..eb39026 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs | |||
@@ -33,6 +33,7 @@ using System.Reflection; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | 38 | ||
38 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | 39 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server |
@@ -56,8 +57,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
56 | 57 | ||
57 | m_listener.Start(50); | 58 | m_listener.Start(50); |
58 | 59 | ||
59 | Thread thread = new Thread(ListenLoop); | 60 | Watchdog.StartThread(ListenLoop, "IRCServer", ThreadPriority.Normal, false); |
60 | thread.Start(); | ||
61 | m_baseScene = baseScene; | 61 | m_baseScene = baseScene; |
62 | } | 62 | } |
63 | 63 | ||
@@ -72,7 +72,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
72 | while (m_running) | 72 | while (m_running) |
73 | { | 73 | { |
74 | AcceptClient(m_listener.AcceptTcpClient()); | 74 | AcceptClient(m_listener.AcceptTcpClient()); |
75 | Watchdog.UpdateThread(); | ||
75 | } | 76 | } |
77 | |||
78 | Watchdog.RemoveThread(); | ||
76 | } | 79 | } |
77 | 80 | ||
78 | private void AcceptClient(TcpClient client) | 81 | private void AcceptClient(TcpClient client) |
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs index 16fe9e9..8d6c41d 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs | |||
@@ -86,7 +86,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
86 | /// </value> | 86 | /// </value> |
87 | Hashtable m_sceneList = Hashtable.Synchronized(new Hashtable()); | 87 | Hashtable m_sceneList = Hashtable.Synchronized(new Hashtable()); |
88 | State m_state = State.NONE; | 88 | State m_state = State.NONE; |
89 | Thread m_thread = null; | ||
90 | CMView m_view = null; | 89 | CMView m_view = null; |
91 | 90 | ||
92 | #endregion Fields | 91 | #endregion Fields |
@@ -148,10 +147,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
148 | lock (this) | 147 | lock (this) |
149 | { | 148 | { |
150 | m_estateModule = scene.RequestModuleInterface<IEstateModule>(); | 149 | m_estateModule = scene.RequestModuleInterface<IEstateModule>(); |
151 | m_thread = new Thread(MainLoop); | 150 | Watchdog.StartThread(MainLoop, "Content Management", ThreadPriority.Normal, true); |
152 | m_thread.Name = "Content Management"; | ||
153 | m_thread.IsBackground = true; | ||
154 | m_thread.Start(); | ||
155 | m_state = State.NONE; | 151 | m_state = State.NONE; |
156 | } | 152 | } |
157 | } | 153 | } |
@@ -200,6 +196,8 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
200 | m_log.Debug("[CONTENT MANAGEMENT] MAIN LOOP -- uuuuuuuuuh, what?"); | 196 | m_log.Debug("[CONTENT MANAGEMENT] MAIN LOOP -- uuuuuuuuuh, what?"); |
201 | break; | 197 | break; |
202 | } | 198 | } |
199 | |||
200 | Watchdog.UpdateThread(); | ||
203 | } | 201 | } |
204 | } | 202 | } |
205 | catch (Exception e) | 203 | catch (Exception e) |
@@ -209,6 +207,8 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
209 | "[CONTENT MANAGEMENT]: Content management thread terminating with exception. PLEASE REBOOT YOUR SIM - CONTENT MANAGEMENT WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}", | 207 | "[CONTENT MANAGEMENT]: Content management thread terminating with exception. PLEASE REBOOT YOUR SIM - CONTENT MANAGEMENT WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}", |
210 | e); | 208 | e); |
211 | } | 209 | } |
210 | |||
211 | Watchdog.RemoveThread(); | ||
212 | } | 212 | } |
213 | 213 | ||
214 | /// <summary> | 214 | /// <summary> |