aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs123
1 files changed, 64 insertions, 59 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 036cb5d..e01d2e4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -28,9 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using System.Threading; 31using System.Threading;
33using log4net;
34using OpenMetaverse; 32using OpenMetaverse;
35using OpenSim.Framework; 33using OpenSim.Framework;
36using OpenSim.Framework.Monitoring; 34using OpenSim.Framework.Monitoring;
@@ -39,6 +37,8 @@ using OpenSim.Region.ScriptEngine.Interfaces;
39using OpenSim.Region.ScriptEngine.Shared; 37using OpenSim.Region.ScriptEngine.Shared;
40using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 38using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
41using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; 39using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
40using System.Reflection;
41using log4net;
42 42
43namespace OpenSim.Region.ScriptEngine.Shared.Api 43namespace OpenSim.Region.ScriptEngine.Shared.Api
44{ 44{
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
51 51
52 private static Thread cmdHandlerThread; 52 private static Thread cmdHandlerThread;
53 private static int cmdHandlerThreadCycleSleepms; 53 private static int cmdHandlerThreadCycleSleepms;
54 54 private static int numInstances;
55 /// <summary> 55 /// <summary>
56 /// Lock for reading/writing static components of AsyncCommandManager. 56 /// Lock for reading/writing static components of AsyncCommandManager.
57 /// </summary> 57 /// </summary>
@@ -81,64 +81,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
81 81
82 public Dataserver DataserverPlugin 82 public Dataserver DataserverPlugin
83 { 83 {
84 get 84 get
85 { 85 {
86 lock (staticLock) 86 lock (staticLock)
87 return m_Dataserver[m_ScriptEngine]; 87 return m_Dataserver[m_ScriptEngine];
88 } 88 }
89 } 89 }
90 90
91 public Timer TimerPlugin 91 public Timer TimerPlugin
92 { 92 {
93 get 93 get
94 { 94 {
95 lock (staticLock) 95 lock (staticLock)
96 return m_Timer[m_ScriptEngine]; 96 return m_Timer[m_ScriptEngine];
97 } 97 }
98 } 98 }
99 99
100 public HttpRequest HttpRequestPlugin 100 public HttpRequest HttpRequestPlugin
101 { 101 {
102 get 102 get
103 { 103 {
104 lock (staticLock) 104 lock (staticLock)
105 return m_HttpRequest[m_ScriptEngine]; 105 return m_HttpRequest[m_ScriptEngine];
106 } 106 }
107 } 107 }
108 108
109 public Listener ListenerPlugin 109 public Listener ListenerPlugin
110 { 110 {
111 get 111 get
112 { 112 {
113 lock (staticLock) 113 lock (staticLock)
114 return m_Listener[m_ScriptEngine]; 114 return m_Listener[m_ScriptEngine];
115 } 115 }
116 } 116 }
117 117
118 public SensorRepeat SensorRepeatPlugin 118 public SensorRepeat SensorRepeatPlugin
119 { 119 {
120 get 120 get
121 { 121 {
122 lock (staticLock) 122 lock (staticLock)
123 return m_SensorRepeat[m_ScriptEngine]; 123 return m_SensorRepeat[m_ScriptEngine];
124 } 124 }
125 } 125 }
126 126
127 public XmlRequest XmlRequestPlugin 127 public XmlRequest XmlRequestPlugin
128 { 128 {
129 get 129 get
130 { 130 {
131 lock (staticLock) 131 lock (staticLock)
132 return m_XmlRequest[m_ScriptEngine]; 132 return m_XmlRequest[m_ScriptEngine];
133 } 133 }
134 } 134 }
135 135
136 public IScriptEngine[] ScriptEngines 136 public IScriptEngine[] ScriptEngines
137 { 137 {
138 get 138 get
139 { 139 {
140 lock (staticLock) 140 lock (staticLock)
141 return m_ScriptEngines.ToArray(); 141 return m_ScriptEngines.ToArray();
142 } 142 }
143 } 143 }
144 144
@@ -172,18 +172,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
172 if (!m_XmlRequest.ContainsKey(m_ScriptEngine)) 172 if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
173 m_XmlRequest[m_ScriptEngine] = new XmlRequest(this); 173 m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
174 174
175 StartThread(); 175 numInstances++;
176 } 176 if (cmdHandlerThread == null)
177 } 177 {
178 178 cmdHandlerThread = WorkManager.StartThread(
179 private static void StartThread()
180 {
181 if (cmdHandlerThread == null)
182 {
183 // Start the thread that will be doing the work
184 cmdHandlerThread
185 = WorkManager.StartThread(
186 CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true); 179 CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true);
180 }
187 } 181 }
188 } 182 }
189 183
@@ -194,25 +188,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
194 cmdHandlerThreadCycleSleepms = 100; 188 cmdHandlerThreadCycleSleepms = 100;
195 } 189 }
196 190
191/*
197 ~AsyncCommandManager() 192 ~AsyncCommandManager()
198 { 193 {
199 // Shut down thread 194 // Shut down thread
200// try
201// {
202// if (cmdHandlerThread != null)
203// {
204// if (cmdHandlerThread.IsAlive == true)
205// {
206// cmdHandlerThread.Abort();
207// //cmdHandlerThread.Join();
208// }
209// }
210// }
211// catch
212// {
213// }
214 }
215 195
196 try
197 {
198 lock (staticLock)
199 {
200 numInstances--;
201 if(numInstances > 0)
202 return;
203 if (cmdHandlerThread != null)
204 {
205 if (cmdHandlerThread.IsAlive == true)
206 {
207 cmdHandlerThread.Abort();
208 //cmdHandlerThread.Join();
209 cmdHandlerThread = null;
210 }
211 }
212 }
213 }
214 catch
215 {
216 }
217 }
218*/
216 /// <summary> 219 /// <summary>
217 /// Main loop for the manager thread 220 /// Main loop for the manager thread
218 /// </summary> 221 /// </summary>
@@ -223,11 +226,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
223 try 226 try
224 { 227 {
225 Thread.Sleep(cmdHandlerThreadCycleSleepms); 228 Thread.Sleep(cmdHandlerThreadCycleSleepms);
226 229 Watchdog.UpdateThread();
227 DoOneCmdHandlerPass(); 230 DoOneCmdHandlerPass();
228
229 Watchdog.UpdateThread(); 231 Watchdog.UpdateThread();
230 } 232 }
233 catch ( System.Threading.ThreadAbortException) { }
231 catch (Exception e) 234 catch (Exception e)
232 { 235 {
233 m_log.Error("[ASYNC COMMAND MANAGER]: Exception in command handler pass: ", e); 236 m_log.Error("[ASYNC COMMAND MANAGER]: Exception in command handler pass: ", e);
@@ -240,24 +243,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
240 lock (staticLock) 243 lock (staticLock)
241 { 244 {
242 // Check HttpRequests 245 // Check HttpRequests
243 m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); 246 try { m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); } catch {}
244 247
245 // Check XMLRPCRequests 248 // Check XMLRPCRequests
246 m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); 249 try { m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); } catch {}
247 250
248 foreach (IScriptEngine s in m_ScriptEngines) 251 foreach (IScriptEngine s in m_ScriptEngines)
249 { 252 {
250 // Check Listeners 253 // Check Listeners
251 m_Listener[s].CheckListeners(); 254 try { m_Listener[s].CheckListeners(); } catch {}
255
252 256
253 // Check timers 257 // Check timers
254 m_Timer[s].CheckTimerEvents(); 258 try { m_Timer[s].CheckTimerEvents(); } catch {}
255 259
256 // Check Sensors 260 // Check Sensors
257 m_SensorRepeat[s].CheckSenseRepeaterEvents(); 261 try { m_SensorRepeat[s].CheckSenseRepeaterEvents(); } catch {}
258 262
259 // Check dataserver 263 // Check dataserver
260 m_Dataserver[s].ExpireRequests(); 264 try { m_Dataserver[s].ExpireRequests(); } catch {}
261 } 265 }
262 } 266 }
263 } 267 }
@@ -269,6 +273,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
269 /// <param name="itemID"></param> 273 /// <param name="itemID"></param>
270 public static void RemoveScript(IScriptEngine engine, uint localID, UUID itemID) 274 public static void RemoveScript(IScriptEngine engine, uint localID, UUID itemID)
271 { 275 {
276 // Remove a specific script
272// m_log.DebugFormat("[ASYNC COMMAND MANAGER]: Removing facilities for script {0}", itemID); 277// m_log.DebugFormat("[ASYNC COMMAND MANAGER]: Removing facilities for script {0}", itemID);
273 278
274 lock (staticLock) 279 lock (staticLock)
@@ -282,7 +287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
282 // Remove from: HttpRequest 287 // Remove from: HttpRequest
283 IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>(); 288 IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>();
284 if (iHttpReq != null) 289 if (iHttpReq != null)
285 iHttpReq.StopHttpRequestsForScript(itemID); 290 iHttpReq.StopHttpRequest(localID, itemID);
286 291
287 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); 292 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
288 if (comms != null) 293 if (comms != null)