ScriptServer fixes: Added more debug logging, mutex lock (to be extra-super-sure) on script load/unload, removed experimental Grid-scriptengine from compile because of dynamic module loader, and added random string to script filename to bypass module loader file lock.

Please delete your copy of bin/ScriptEngine/OpenSim.Grid.ScriptEngine.DotNetEngine.dll.
afrisby
Tedd Hansen 2007-11-01 19:27:03 +00:00
parent 4fad66f855
commit dcf41cb683
6 changed files with 98 additions and 118 deletions

View File

@ -82,6 +82,10 @@ namespace OpenSim.Region.ScriptEngine.Common
string EventName = m_Script.State() + "_event_" + FunctionName;
#if DEBUG
Console.WriteLine("ScriptEngine: Script event function name: " + EventName);
#endif
//type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args);
//Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\"");
@ -112,6 +116,9 @@ namespace OpenSim.Region.ScriptEngine.Common
return;
}
#if DEBUG
Console.WriteLine("ScriptEngine: Executing function name: " + EventName);
#endif
// Found
//try
//{

View File

@ -39,6 +39,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
private LSL2CSConverter LSL_Converter = new LSL2CSConverter();
private CSharpCodeProvider codeProvider = new CSharpCodeProvider();
private static UInt64 scriptCompileCounter = 0;
private static int instanceID = new Random().Next(0, int.MaxValue); // Implemented due to peer preassure --- will cause garbage in ScriptEngines folder ;)
//private ICodeCompiler icc = codeProvider.CreateCompiler();
public string CompileFromFile(string LSOFileName)
{
@ -82,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{
// Output assembly name
scriptCompileCounter++;
string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll");
string OutFile = Path.Combine("ScriptEngines", "DotNetScript_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll");
try
{
File.Delete(OutFile);

View File

@ -53,6 +53,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
public string Convert(string Script)
{
quotes.Clear();
string Return = "";
Script = " \r\n" + Script;
@ -310,6 +311,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
Return += Script;
Return += "} }\r\n";
quotes.Clear();
return Return;
}
}

View File

@ -181,6 +181,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Execute function
try
{
#if DEBUG
m_ScriptEngine.Log.Debug("ScriptEngine", "Executing event:\r\n"
+ "QIS.localID: " + QIS.localID
+ ", QIS.itemID: " + QIS.itemID
+ ", QIS.functionName: " + QIS.functionName);
#endif
m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID,
QIS.functionName, QIS.param);
}
@ -188,16 +194,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
// DISPLAY ERROR INWORLD
string text = "Error executing script function \"" + QIS.functionName + "\":\r\n";
if (e.InnerException != null)
{
//if (e.InnerException != null)
//{
// Send inner exception
text += e.InnerException.Message.ToString();
}
else
{
//}
//else
//{
text += "\r\n";
// Send normal
text += e.Message.ToString();
}
//}
try
{
if (text.Length > 1500)
@ -214,7 +221,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
//else
//{
// T oconsole
Console.WriteLine("Unable to send text in-world:\r\n" + text);
m_ScriptEngine.Log.Error("ScriptEngine", "Unable to send text in-world:\r\n" + text);
}
}
finally
@ -230,7 +237,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (Exception e)
{
Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString());
m_ScriptEngine.Log.Error("ScriptEngine", "Exception in EventQueueThreadLoop: " + e.ToString());
}
} // while
} // try

View File

@ -225,6 +225,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
#region Start/Stop/Reset script
Object startStopLock = new Object();
/// <summary>
/// Fetches, loads and hooks up a script to an objects events
/// </summary>
@ -259,76 +261,83 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
StartScript(localID, itemID, script);
}
// Create a new instance of the compiler (reuse)
Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();
private void _StartScript(uint localID, LLUUID itemID, string Script)
{
//IScriptHost root = host.GetRoot();
Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID);
// We will initialize and start the script.
// It will be up to the script itself to hook up the correct events.
string ScriptSource = "";
SceneObjectPart m_host = World.GetSceneObjectPart(localID);
try
lock (startStopLock)
{
// Create a new instance of the compiler (currently we don't want reuse)
Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();
// Compile (We assume LSL)
ScriptSource = LSLCompiler.CompileFromLSLText(Script);
//Console.WriteLine("Compilation of " + FileName + " done");
// * Insert yield into code
ScriptSource = ProcessYield(ScriptSource);
//IScriptHost root = host.GetRoot();
Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID);
// We will initialize and start the script.
// It will be up to the script itself to hook up the correct events.
string ScriptSource = "";
#if DEBUG
long before;
before = GC.GetTotalMemory(true);
#endif
SceneObjectPart m_host = World.GetSceneObjectPart(localID);
LSL_BaseClass CompiledScript;
CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
#if DEBUG
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
#endif
CompiledScript.SourceCode = ScriptSource;
// Add it to our script memstruct
SetScript(localID, itemID, CompiledScript);
// We need to give (untrusted) assembly a private instance of BuiltIns
// this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID);
// Start the script - giving it BuiltIns
CompiledScript.Start(LSLB);
// Fire the first start-event
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] {});
}
catch (Exception e)
{
//m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
try
{
// DISPLAY ERROR INWORLD
string text = "Error compiling script:\r\n" + e.Message.ToString();
if (text.Length > 1500)
text = text.Substring(0, 1500);
World.SimChat(Helpers.StringToField(text), 1, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
// Compile (We assume LSL)
ScriptSource = LSLCompiler.CompileFromLSLText(Script);
//Console.WriteLine("Compilation of " + FileName + " done");
// * Insert yield into code
ScriptSource = ProcessYield(ScriptSource);
#if DEBUG
long before;
before = GC.GetTotalMemory(true);
#endif
LSL_BaseClass CompiledScript;
CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
#if DEBUG
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
#endif
CompiledScript.SourceCode = ScriptSource;
// Add it to our script memstruct
SetScript(localID, itemID, CompiledScript);
// We need to give (untrusted) assembly a private instance of BuiltIns
// this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID);
// Start the script - giving it BuiltIns
CompiledScript.Start(LSLB);
// Fire the first start-event
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { });
}
catch (Exception e2)
catch (Exception e)
{
m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
//m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
try
{
// DISPLAY ERROR INWORLD
string text = "Error compiling script:\r\n" + e.Message.ToString();
if (text.Length > 1500)
text = text.Substring(0, 1500);
World.SimChat(Helpers.StringToField(text), 1, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
}
catch (Exception e2)
{
m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
m_scriptEngine.Log.Error("ScriptEngine", "Errormessage: Error compiling script:\r\n" + e.Message.ToString());
}
}
}
}
private void _StopScript(uint localID, LLUUID itemID)
{
lock (startStopLock)
{
// Stop script
Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
@ -361,6 +370,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
": " + e.ToString());
}
}
}
private string ProcessYield(string FileName)
{
@ -382,12 +392,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="args">Arguments to pass to function</param>
internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args)
{
#if DEBUG
Console.WriteLine("ScriptEngine: Inside ExecuteEvent for event " + FunctionName);
#endif
// Execute a function in the script
//m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID);
if (Script == null)
return;
#if DEBUG
Console.WriteLine("ScriptEngine: Executing event: " + FunctionName);
#endif
// Must be done in correct AppDomain, so leaving it up to the script itself
Script.Exec.ExecuteEvent(FunctionName, args);
}

View File

@ -963,61 +963,6 @@
</Project>
<Project name="OpenSim.Grid.ScriptEngine.Common" path="OpenSim/Grid/ScriptEngine/Common" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../../bin/</ReferencePath>
<ReferencePath>../../../../bin/ScriptEngines/</ReferencePath>
<Reference name="System" localCopy="false"/>
<Reference name="System.Data" localCopy="false"/>
<Reference name="System.Xml" localCopy="false"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project name="OpenSim.Grid.ScriptEngine.DotNetEngine" path="OpenSim/Grid/ScriptEngine/DotNetEngine" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../../bin/ScriptEngines/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../../bin/ScriptEngines/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../../bin/</ReferencePath>
<ReferencePath>../../../../bin/ScriptEngines/</ReferencePath>
<Reference name="System" localCopy="false"/>
<Reference name="System.Data" localCopy="false"/>
<Reference name="System.Xml" localCopy="false"/>
<Reference name="System.Runtime.Remoting" localCopy="false"/>
<Reference name="OpenSim.Region.Environment" />
<Reference name="libsecondlife.dll"/>
<Reference name="RAIL.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.ScriptEngine.Common"/>
<Reference name="Axiom.MathLib.dll" localCopy="false"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>