From edd6577f84cb4714c8d1c0b156ffbddfe3b1f87e Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Wed, 7 May 2008 18:10:18 +0000
Subject: while I'm not convinced this is causing my current run away loop,
this queue manipulation is dead wrong as Queue is not a synchronized data
structure. Hopefully this helps.
---
.../Common/ScriptEngineBase/ScriptManager.cs | 39 ++++++++++++----------
1 file changed, 21 insertions(+), 18 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs')
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
index 7812c8c..f5de967 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
@@ -207,11 +207,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void DoScriptLoadUnload()
{
- if (LUQueue.Count > 0)
- {
- LUStruct item = LUQueue.Dequeue();
- lock (startStopLock) // Lock so we have only 1 thread working on loading/unloading of scripts
+ lock (LUQueue) {
+ if (LUQueue.Count > 0)
{
+ LUStruct item = LUQueue.Dequeue();
+
if (item.Action == LUType.Unload)
{
_StopScript(item.localID, item.itemID);
@@ -222,9 +222,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
}
}
}
-
}
-
+
#endregion
#region Helper functions
@@ -250,18 +249,20 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
///
public void StartScript(uint localID, LLUUID itemID, string Script)
{
- if (LUQueue.Count >= LoadUnloadMaxQueueSize)
- {
- m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: ERROR: Load/unload queue item count is at " + LUQueue.Count + ". Config variable \"LoadUnloadMaxQueueSize\" is set to " + LoadUnloadMaxQueueSize + ", so ignoring new script.");
- return;
- }
+ lock(LUQueue) {
+ if (LUQueue.Count >= LoadUnloadMaxQueueSize)
+ {
+ m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: ERROR: Load/unload queue item count is at " + LUQueue.Count + ". Config variable \"LoadUnloadMaxQueueSize\" is set to " + LoadUnloadMaxQueueSize + ", so ignoring new script.");
+ return;
+ }
- LUStruct ls = new LUStruct();
- ls.localID = localID;
- ls.itemID = itemID;
- ls.script = Script;
- ls.Action = LUType.Load;
- LUQueue.Enqueue(ls);
+ LUStruct ls = new LUStruct();
+ ls.localID = localID;
+ ls.itemID = itemID;
+ ls.script = Script;
+ ls.Action = LUType.Load;
+ LUQueue.Enqueue(ls);
+ }
}
///
@@ -275,7 +276,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
ls.localID = localID;
ls.itemID = itemID;
ls.Action = LUType.Unload;
- LUQueue.Enqueue(ls);
+ lock (LUQueue) {
+ LUQueue.Enqueue(ls);
+ }
}
// Create a new instance of the compiler (reuse)
--
cgit v1.1