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.
0.6.0-stable
Sean Dague 2008-05-07 18:10:18 +00:00
parent 1b2415325a
commit edd6577f84
1 changed files with 21 additions and 18 deletions

View File

@ -207,11 +207,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void DoScriptLoadUnload() public void DoScriptLoadUnload()
{ {
lock (LUQueue) {
if (LUQueue.Count > 0) if (LUQueue.Count > 0)
{ {
LUStruct item = LUQueue.Dequeue(); LUStruct item = LUQueue.Dequeue();
lock (startStopLock) // Lock so we have only 1 thread working on loading/unloading of scripts
{
if (item.Action == LUType.Unload) if (item.Action == LUType.Unload)
{ {
_StopScript(item.localID, item.itemID); _StopScript(item.localID, item.itemID);
@ -222,7 +222,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
} }
} }
} }
#endregion #endregion
@ -250,6 +249,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <param name="localID"></param> /// <param name="localID"></param>
public void StartScript(uint localID, LLUUID itemID, string Script) public void StartScript(uint localID, LLUUID itemID, string Script)
{ {
lock(LUQueue) {
if (LUQueue.Count >= LoadUnloadMaxQueueSize) 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."); 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.");
@ -263,6 +263,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
ls.Action = LUType.Load; ls.Action = LUType.Load;
LUQueue.Enqueue(ls); LUQueue.Enqueue(ls);
} }
}
/// <summary> /// <summary>
/// Disables and unloads a script /// Disables and unloads a script
@ -275,8 +276,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
ls.localID = localID; ls.localID = localID;
ls.itemID = itemID; ls.itemID = itemID;
ls.Action = LUType.Unload; ls.Action = LUType.Unload;
lock (LUQueue) {
LUQueue.Enqueue(ls); LUQueue.Enqueue(ls);
} }
}
// Create a new instance of the compiler (reuse) // Create a new instance of the compiler (reuse)
//private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); //private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();