diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 93 |
1 files changed, 45 insertions, 48 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f9f8883..8ad8110 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -145,11 +145,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
145 | public void Initialise(Scene scene, IConfigSource configSource) | 145 | public void Initialise(Scene scene, IConfigSource configSource) |
146 | { | 146 | { |
147 | AppDomain.CurrentDomain.AssemblyResolve += | 147 | AppDomain.CurrentDomain.AssemblyResolve += |
148 | OnAssemblyResolve; | 148 | OnAssemblyResolve; |
149 | 149 | ||
150 | m_log.InfoFormat("[XEngine] Initializing scripts in region {0}", | 150 | m_log.InfoFormat("[XEngine] Initializing scripts in region {0}", |
151 | scene.RegionInfo.RegionName); | 151 | scene.RegionInfo.RegionName); |
152 | m_Scene=scene; | 152 | m_Scene = scene; |
153 | 153 | ||
154 | m_ScriptConfig = configSource.Configs["XEngine"]; | 154 | m_ScriptConfig = configSource.Configs["XEngine"]; |
155 | 155 | ||
@@ -165,34 +165,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
165 | string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); | 165 | string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); |
166 | int maxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); | 166 | int maxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); |
167 | int stackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); | 167 | int stackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); |
168 | int sleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", | 168 | int sleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10)*1000; |
169 | 10)*1000; | ||
170 | m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); | 169 | m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); |
171 | m_KillTimedOutScripts = m_ScriptConfig.GetBoolean( | 170 | m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); |
172 | "KillTimedOutScripts", false); | ||
173 | int saveTime = m_ScriptConfig.GetInt("SaveInterval", 300)*1000; | 171 | int saveTime = m_ScriptConfig.GetInt("SaveInterval", 300)*1000; |
174 | 172 | ||
175 | ThreadPriority prio = ThreadPriority.BelowNormal; | 173 | ThreadPriority prio = ThreadPriority.BelowNormal; |
176 | switch (priority) | 174 | switch (priority) |
177 | { | 175 | { |
178 | case "Lowest": | 176 | case "Lowest": |
179 | prio=ThreadPriority.Lowest; | 177 | prio = ThreadPriority.Lowest; |
180 | break; | 178 | break; |
181 | case "BelowNormal": | 179 | case "BelowNormal": |
182 | prio=ThreadPriority.BelowNormal; | 180 | prio = ThreadPriority.BelowNormal; |
183 | break; | 181 | break; |
184 | case "Normal": | 182 | case "Normal": |
185 | prio=ThreadPriority.Normal; | 183 | prio = ThreadPriority.Normal; |
186 | break; | 184 | break; |
187 | case "AboveNormal": | 185 | case "AboveNormal": |
188 | prio=ThreadPriority.AboveNormal; | 186 | prio = ThreadPriority.AboveNormal; |
189 | break; | 187 | break; |
190 | case "Highest": | 188 | case "Highest": |
191 | prio=ThreadPriority.Highest; | 189 | prio = ThreadPriority.Highest; |
192 | break; | 190 | break; |
193 | default: | 191 | default: |
194 | m_log.ErrorFormat("[XEngine] Invalid thread priority: '"+ | 192 | m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority); |
195 | priority+"'. Assuming BelowNormal"); | ||
196 | break; | 193 | break; |
197 | } | 194 | } |
198 | 195 | ||
@@ -204,7 +201,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
204 | m_EventManager = new EventManager(this); | 201 | m_EventManager = new EventManager(this); |
205 | 202 | ||
206 | StartEngine(minThreads, maxThreads, idleTimeout, prio, | 203 | StartEngine(minThreads, maxThreads, idleTimeout, prio, |
207 | maxScriptQueue, stackSize); | 204 | maxScriptQueue, stackSize); |
208 | 205 | ||
209 | m_Compiler = new Compiler(this); | 206 | m_Compiler = new Compiler(this); |
210 | 207 | ||
@@ -218,15 +215,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
218 | 215 | ||
219 | if (sleepTime > 0) | 216 | if (sleepTime > 0) |
220 | { | 217 | { |
221 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 218 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), |
222 | this.DoMaintenance), new Object[] | 219 | new Object[]{ sleepTime }); |
223 | { sleepTime }); | ||
224 | } | 220 | } |
225 | 221 | ||
226 | if (saveTime > 0) | 222 | if (saveTime > 0) |
227 | { | 223 | { |
228 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 224 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), |
229 | this.DoBackup), new Object[] { saveTime }); | 225 | new Object[] { saveTime }); |
230 | } | 226 | } |
231 | 227 | ||
232 | scene.RegisterModuleInterface<IScriptModule>(this); | 228 | scene.RegisterModuleInterface<IScriptModule>(this); |
@@ -279,8 +275,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
279 | 275 | ||
280 | instances.Clear(); | 276 | instances.Clear(); |
281 | 277 | ||
282 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 278 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), |
283 | this.DoBackup), new Object[] { saveTime }); | 279 | new Object[] { saveTime }); |
284 | 280 | ||
285 | return 0; | 281 | return 0; |
286 | } | 282 | } |
@@ -302,9 +298,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
302 | 298 | ||
303 | System.Threading.Thread.Sleep(sleepTime); | 299 | System.Threading.Thread.Sleep(sleepTime); |
304 | 300 | ||
305 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 301 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), |
306 | this.DoMaintenance), new Object[] | 302 | new Object[]{ sleepTime }); |
307 | { sleepTime }); | ||
308 | 303 | ||
309 | return 0; | 304 | return 0; |
310 | } | 305 | } |
@@ -321,25 +316,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
321 | 316 | ||
322 | public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) | 317 | public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) |
323 | { | 318 | { |
324 | Object[] parms = new Object[] | 319 | Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez}; |
325 | { localID, itemID, script, startParam, postOnRez}; | ||
326 | 320 | ||
327 | lock (m_CompileQueue) | 321 | lock (m_CompileQueue) |
328 | { | 322 | { |
329 | m_CompileQueue.Enqueue(parms); | 323 | m_CompileQueue.Enqueue(parms); |
324 | |||
330 | if (m_CurrentCompile == null) | 325 | if (m_CurrentCompile == null) |
331 | { | 326 | { |
332 | if (m_firstStart) | 327 | if (m_firstStart) |
333 | { | 328 | { |
334 | m_firstStart = false; | 329 | m_firstStart = false; |
335 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | 330 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( |
336 | new WorkItemCallback( | 331 | new WorkItemCallback(this.DoScriptWait), |
337 | this.DoScriptWait), new Object[0]); | 332 | new Object[0]); |
338 | return; | 333 | return; |
339 | } | 334 | } |
335 | |||
340 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | 336 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( |
341 | new WorkItemCallback( | 337 | new WorkItemCallback(this.DoOnRezScriptQueue), |
342 | this.DoOnRezScriptQueue), new Object[0]); | 338 | new Object[0]); |
343 | } | 339 | } |
344 | } | 340 | } |
345 | } | 341 | } |
@@ -353,8 +349,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
353 | if (m_CompileQueue.Count > 0) | 349 | if (m_CompileQueue.Count > 0) |
354 | { | 350 | { |
355 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | 351 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( |
356 | new WorkItemCallback( | 352 | new WorkItemCallback(this.DoOnRezScriptQueue), |
357 | this.DoOnRezScriptQueue), new Object[0]); | 353 | new Object[0]); |
358 | } | 354 | } |
359 | else | 355 | else |
360 | { | 356 | { |
@@ -384,8 +380,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
384 | if (m_CompileQueue.Count > 0) | 380 | if (m_CompileQueue.Count > 0) |
385 | { | 381 | { |
386 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | 382 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( |
387 | new WorkItemCallback( | 383 | new WorkItemCallback(this.DoOnRezScriptQueue), |
388 | this.DoOnRezScriptQueue), new Object[0]); | 384 | new Object[0]); |
389 | } | 385 | } |
390 | else | 386 | else |
391 | { | 387 | { |
@@ -459,7 +455,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
459 | if ((!m_Scripts.ContainsKey(itemID)) || | 455 | if ((!m_Scripts.ContainsKey(itemID)) || |
460 | (m_Scripts[itemID].AssetID != assetID)) | 456 | (m_Scripts[itemID].AssetID != assetID)) |
461 | { | 457 | { |
462 | LLUUID appDomain=assetID; | 458 | LLUUID appDomain = assetID; |
463 | 459 | ||
464 | if (part.ParentGroup.RootPart.IsAttachment) | 460 | if (part.ParentGroup.RootPart.IsAttachment) |
465 | appDomain = part.ParentGroup.RootPart.UUID; | 461 | appDomain = part.ParentGroup.RootPart.UUID; |
@@ -473,8 +469,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
473 | // "ScriptEngines", | 469 | // "ScriptEngines", |
474 | // m_Scene.RegionInfo.RegionID.ToString()); | 470 | // m_Scene.RegionInfo.RegionID.ToString()); |
475 | 471 | ||
476 | Evidence baseEvidence = | 472 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
477 | AppDomain.CurrentDomain.Evidence; | ||
478 | Evidence evidence = new Evidence(baseEvidence); | 473 | Evidence evidence = new Evidence(baseEvidence); |
479 | 474 | ||
480 | m_AppDomains[appDomain] = | 475 | m_AppDomains[appDomain] = |
@@ -489,18 +484,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
489 | } | 484 | } |
490 | catch (Exception e) | 485 | catch (Exception e) |
491 | { | 486 | { |
492 | m_log.Error("[XEngine] Exception creating app domain:\n"+e.ToString()); | 487 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
493 | return false; | 488 | return false; |
494 | } | 489 | } |
495 | } | 490 | } |
496 | m_DomainScripts[appDomain].Add(itemID); | 491 | m_DomainScripts[appDomain].Add(itemID); |
497 | 492 | ||
498 | ScriptInstance instance = new ScriptInstance(this,localID, | 493 | ScriptInstance instance = |
499 | part.UUID, itemID, assetID, assembly, | 494 | new ScriptInstance(this,localID, |
500 | m_AppDomains[appDomain], | 495 | part.UUID, itemID, assetID, assembly, |
501 | part.ParentGroup.RootPart.Name, | 496 | m_AppDomains[appDomain], |
502 | item.Name, startParam, postOnRez, | 497 | part.ParentGroup.RootPart.Name, |
503 | StateSource.NewRez, m_MaxScriptQueue); | 498 | item.Name, startParam, postOnRez, |
499 | StateSource.NewRez, m_MaxScriptQueue); | ||
504 | 500 | ||
505 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", | 501 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", |
506 | part.ParentGroup.RootPart.Name, item.Name); | 502 | part.ParentGroup.RootPart.Name, item.Name); |
@@ -657,8 +653,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
657 | // | 653 | // |
658 | public IScriptWorkItem QueueEventHandler(object parms) | 654 | public IScriptWorkItem QueueEventHandler(object parms) |
659 | { | 655 | { |
660 | return new XWorkItem(m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 656 | return new XWorkItem(m_ThreadPool.QueueWorkItem( |
661 | this.ProcessEventHandler), parms)); | 657 | new WorkItemCallback(this.ProcessEventHandler), |
658 | parms)); | ||
662 | } | 659 | } |
663 | 660 | ||
664 | // | 661 | // |
@@ -723,7 +720,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
723 | string[] pathList = new string[] {"bin", "ScriptEngines", | 720 | string[] pathList = new string[] {"bin", "ScriptEngines", |
724 | Path.Combine("ScriptEngines", | 721 | Path.Combine("ScriptEngines", |
725 | m_Scene.RegionInfo.RegionID.ToString())}; | 722 | m_Scene.RegionInfo.RegionID.ToString())}; |
726 | 723 | ||
727 | string assemblyName = args.Name; | 724 | string assemblyName = args.Name; |
728 | if (assemblyName.IndexOf(",") != -1) | 725 | if (assemblyName.IndexOf(",") != -1) |
729 | assemblyName = args.Name.Substring(0, args.Name.IndexOf(",")); | 726 | assemblyName = args.Name.Substring(0, args.Name.IndexOf(",")); |