aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs27
1 files changed, 19 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index b0fce75..a60c0ba 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -51,7 +51,6 @@ using OpenSim.Region.ScriptEngine.Shared.Instance;
51using OpenSim.Region.ScriptEngine.Interfaces; 51using OpenSim.Region.ScriptEngine.Interfaces;
52 52
53using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; 53using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>;
54using Parallel = OpenSim.Framework.Parallel;
55 54
56namespace OpenSim.Region.ScriptEngine.XEngine 55namespace OpenSim.Region.ScriptEngine.XEngine
57{ 56{
@@ -494,7 +493,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
494 493
495 if (m_CurrentCompile == null) 494 if (m_CurrentCompile == null)
496 { 495 {
497 m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); 496 // NOTE: Although we use a lockless queue, the lock here
497 // is required. It ensures that there are never two
498 // compile threads running, which, due to a race
499 // conndition, might otherwise happen
500 //
501 lock (m_CompileQueue)
502 {
503 if (m_CurrentCompile == null)
504 m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null);
505 }
498 } 506 }
499 } 507 }
500 } 508 }
@@ -514,16 +522,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
514 } 522 }
515 } 523 }
516 524
517 List<object[]> compiles = new List<object[]>();
518 object[] o; 525 object[] o;
519 while (m_CompileQueue.Dequeue(out o)) 526 while (m_CompileQueue.Dequeue(out o))
527 DoOnRezScript(o);
528
529 // NOTE: Despite having a lockless queue, this lock is required
530 // to make sure there is never no compile thread while there
531 // are still scripts to compile. This could otherwise happen
532 // due to a race condition
533 //
534 lock (m_CompileQueue)
520 { 535 {
521 compiles.Add(o); 536 m_CurrentCompile = null;
522 } 537 }
523
524 Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); });
525
526 m_CurrentCompile = null;
527 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, 538 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
528 m_ScriptErrorMessage); 539 m_ScriptErrorMessage);
529 m_ScriptFailCount = 0; 540 m_ScriptFailCount = 0;