If ScriptStopStrategy hasn't been set to co-op in [XEngine] config, then continue to generate C# that is functionality identical to historical generation
This is to eliminate disruption until co-op termination has been well-tested. In non co-op mode, XEngine will continue to load DLLs of the existing Script class and the new XEngineScript class. Moving to co-op mode still requires existing script DLL deletion to force recompilation, either manually or by setting DeleteScriptsOnStartup = true for one run. This change also means that scripts which fail to initialize do not still show up as running scripts.0.7.4-extended
parent
3f80ac23b6
commit
b2c893a7be
|
@ -78,6 +78,14 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
||||||
string ScriptEngineName { get; }
|
string ScriptEngineName { get; }
|
||||||
string ScriptEnginePath { get; }
|
string ScriptEnginePath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return the name of the class that will be used for all running scripts.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Each class goes in its own assembly so we don't need to otherwise distinguish the class name.
|
||||||
|
/// </remarks>
|
||||||
|
string ScriptClassName { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the name of the base class that will be used for all running scripts.
|
/// Return the name of the base class that will be used for all running scripts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -416,16 +416,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
case enumCompileType.cs:
|
case enumCompileType.cs:
|
||||||
case enumCompileType.lsl:
|
case enumCompileType.lsl:
|
||||||
compileScript = CreateCSCompilerScript(
|
compileScript = CreateCSCompilerScript(
|
||||||
compileScript, m_scriptEngine.ScriptBaseClassName, m_scriptEngine.ScriptBaseClassParameters);
|
compileScript,
|
||||||
|
m_scriptEngine.ScriptClassName,
|
||||||
|
m_scriptEngine.ScriptBaseClassName,
|
||||||
|
m_scriptEngine.ScriptBaseClassParameters);
|
||||||
break;
|
break;
|
||||||
case enumCompileType.vb:
|
case enumCompileType.vb:
|
||||||
compileScript = CreateVBCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName);
|
compileScript = CreateVBCompilerScript(
|
||||||
|
compileScript, m_scriptEngine.ScriptClassName, m_scriptEngine.ScriptBaseClassName);
|
||||||
break;
|
break;
|
||||||
// case enumCompileType.js:
|
// case enumCompileType.js:
|
||||||
// compileScript = CreateJSCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName);
|
// compileScript = CreateJSCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName);
|
||||||
// break;
|
// break;
|
||||||
case enumCompileType.yp:
|
case enumCompileType.yp:
|
||||||
compileScript = CreateYPCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName);
|
compileScript = CreateYPCompilerScript(
|
||||||
|
compileScript, m_scriptEngine.ScriptClassName,m_scriptEngine.ScriptBaseClassName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static string CreateCSCompilerScript(
|
private static string CreateCSCompilerScript(
|
||||||
string compileScript, string baseClassName, ParameterInfo[] constructorParameters)
|
string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters)
|
||||||
{
|
{
|
||||||
compileScript = string.Format(
|
compileScript = string.Format(
|
||||||
@"using OpenSim.Region.ScriptEngine.Shared;
|
@"using OpenSim.Region.ScriptEngine.Shared;
|
||||||
|
@ -465,12 +470,13 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SecondLife
|
namespace SecondLife
|
||||||
{{
|
{{
|
||||||
public class Script : {0}
|
public class {0} : {1}
|
||||||
{{
|
{{
|
||||||
public Script({1}) : base({2}) {{}}
|
public {0}({2}) : base({3}) {{}}
|
||||||
{3}
|
{4}
|
||||||
}}
|
}}
|
||||||
}}",
|
}}",
|
||||||
|
className,
|
||||||
baseClassName,
|
baseClassName,
|
||||||
constructorParameters != null
|
constructorParameters != null
|
||||||
? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString()))
|
? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString()))
|
||||||
|
@ -483,28 +489,28 @@ namespace SecondLife
|
||||||
return compileScript;
|
return compileScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string CreateYPCompilerScript(string compileScript, string baseClassName)
|
private static string CreateYPCompilerScript(string compileScript, string className, string baseClassName)
|
||||||
{
|
{
|
||||||
compileScript = String.Empty +
|
compileScript = String.Empty +
|
||||||
"using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
|
"using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
|
||||||
"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
|
"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
|
||||||
String.Empty + "namespace SecondLife { " +
|
String.Empty + "namespace SecondLife { " +
|
||||||
String.Empty + "public class Script : " + baseClassName + " { \r\n" +
|
String.Empty + "public class " + className + " : " + baseClassName + " { \r\n" +
|
||||||
//@"public Script() { } " +
|
//@"public Script() { } " +
|
||||||
@"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
|
@"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
|
||||||
@"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
|
@"public " + className + "() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
|
||||||
compileScript +
|
compileScript +
|
||||||
"} }\r\n";
|
"} }\r\n";
|
||||||
|
|
||||||
return compileScript;
|
return compileScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string CreateVBCompilerScript(string compileScript, string baseClassName)
|
private static string CreateVBCompilerScript(string compileScript, string className, string baseClassName)
|
||||||
{
|
{
|
||||||
compileScript = String.Empty +
|
compileScript = String.Empty +
|
||||||
"Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
|
"Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
|
||||||
String.Empty + "NameSpace SecondLife:" +
|
String.Empty + "NameSpace SecondLife:" +
|
||||||
String.Empty + "Public Class Script: Inherits " + baseClassName +
|
String.Empty + "Public Class " + className + ": Inherits " + baseClassName +
|
||||||
"\r\nPublic Sub New()\r\nEnd Sub: " +
|
"\r\nPublic Sub New()\r\nEnd Sub: " +
|
||||||
compileScript +
|
compileScript +
|
||||||
":End Class :End Namespace\r\n";
|
":End Class :End Namespace\r\n";
|
||||||
|
|
|
@ -251,7 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
/// <param name='dom'></param>
|
/// <param name='dom'></param>
|
||||||
/// <param name='assembly'></param>
|
/// <param name='assembly'></param>
|
||||||
/// <param name='stateSource'></param>
|
/// <param name='stateSource'></param>
|
||||||
public void Load(AppDomain dom, string assembly, StateSource stateSource)
|
/// <returns>false if load failed, true if suceeded</returns>
|
||||||
|
public bool Load(AppDomain dom, string assembly, StateSource stateSource)
|
||||||
{
|
{
|
||||||
m_Assembly = assembly;
|
m_Assembly = assembly;
|
||||||
m_stateSource = stateSource;
|
m_stateSource = stateSource;
|
||||||
|
@ -266,26 +267,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
object[] constructorParams;
|
||||||
|
|
||||||
|
Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly));
|
||||||
|
Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript");
|
||||||
|
|
||||||
|
if (scriptType != null)
|
||||||
|
{
|
||||||
|
constructorParams = new object[] { m_coopSleepHandle };
|
||||||
|
}
|
||||||
|
else if (!m_coopTermination)
|
||||||
|
{
|
||||||
|
scriptType = scriptAssembly.GetType("SecondLife.Script");
|
||||||
|
constructorParams = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[SCRIPT INSTANCE]: You must remove all existing script DLLs before using enabling co-op termination"
|
||||||
|
+ ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run"
|
||||||
|
+ " or by deleting all *.dll* files in the relevant bin/ScriptEngines/<region-id>/ directory");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}",
|
||||||
|
// scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name);
|
||||||
|
|
||||||
if (dom != System.AppDomain.CurrentDomain)
|
if (dom != System.AppDomain.CurrentDomain)
|
||||||
m_Script
|
m_Script
|
||||||
= (IScript)dom.CreateInstanceAndUnwrap(
|
= (IScript)dom.CreateInstanceAndUnwrap(
|
||||||
Path.GetFileNameWithoutExtension(assembly),
|
Path.GetFileNameWithoutExtension(assembly),
|
||||||
"SecondLife.Script",
|
scriptType.FullName,
|
||||||
false,
|
false,
|
||||||
BindingFlags.Default,
|
BindingFlags.Default,
|
||||||
null,
|
null,
|
||||||
new object[] { m_coopSleepHandle },
|
constructorParams,
|
||||||
null,
|
|
||||||
null,
|
null,
|
||||||
null);
|
null);
|
||||||
else
|
else
|
||||||
m_Script
|
m_Script
|
||||||
= (IScript)Assembly.Load(Path.GetFileNameWithoutExtension(assembly)).CreateInstance(
|
= (IScript)scriptAssembly.CreateInstance(
|
||||||
"SecondLife.Script",
|
scriptType.FullName,
|
||||||
false,
|
false,
|
||||||
BindingFlags.Default,
|
BindingFlags.Default,
|
||||||
null,
|
null,
|
||||||
new object[] { m_coopSleepHandle },
|
constructorParams,
|
||||||
null,
|
null,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
|
@ -298,6 +326,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}",
|
"[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}",
|
||||||
assembly, e.Message, e.StackTrace);
|
assembly, e.Message, e.StackTrace);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -318,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
"[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}",
|
"[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}",
|
||||||
assembly, e.Message, e.StackTrace);
|
assembly, e.Message, e.StackTrace);
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_SaveState = true;
|
m_SaveState = true;
|
||||||
|
@ -390,6 +420,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
|
// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
|
||||||
public void TestStopOnInfiniteJumpLoop()
|
public void TestStopOnInfiniteJumpLoop()
|
||||||
{
|
{
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// TestHelpers.EnableLogging();
|
TestHelpers.EnableLogging();
|
||||||
|
|
||||||
string script =
|
string script =
|
||||||
@"default
|
@"default
|
||||||
|
|
|
@ -46,13 +46,14 @@ using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
using OpenSim.Region.ScriptEngine.Shared;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.Instance;
|
using OpenSim.Region.ScriptEngine.Shared.Instance;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
using OpenSim.Region.ScriptEngine.Shared.Api;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
||||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||||
using OpenSim.Region.ScriptEngine.XEngine.ScriptBase;
|
using OpenSim.Region.ScriptEngine.XEngine.ScriptBase;
|
||||||
using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
|
using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
|
||||||
|
|
||||||
|
@ -177,6 +178,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
get { return "XEngine"; }
|
get { return "XEngine"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ScriptClassName { get; private set; }
|
||||||
|
|
||||||
public string ScriptBaseClassName { get; private set; }
|
public string ScriptBaseClassName { get; private set; }
|
||||||
|
|
||||||
public ParameterInfo[] ScriptBaseClassParameters { get; private set; }
|
public ParameterInfo[] ScriptBaseClassParameters { get; private set; }
|
||||||
|
@ -238,9 +241,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
m_ScriptConfig = configSource.Configs["XEngine"];
|
m_ScriptConfig = configSource.Configs["XEngine"];
|
||||||
m_ConfigSource = configSource;
|
m_ConfigSource = configSource;
|
||||||
|
|
||||||
|
if (m_ScriptConfig.GetString("ScriptStopStrategy", "abort") == "co-op")
|
||||||
|
{
|
||||||
|
ScriptClassName = "XEngineScript";
|
||||||
ScriptBaseClassName = typeof(XEngineScriptBase).FullName;
|
ScriptBaseClassName = typeof(XEngineScriptBase).FullName;
|
||||||
ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters();
|
ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters();
|
||||||
ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) };
|
ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ScriptClassName = "Script";
|
||||||
|
ScriptBaseClassName = typeof(ScriptBaseClass).FullName;
|
||||||
|
}
|
||||||
|
|
||||||
// Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]);
|
// Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]);
|
||||||
}
|
}
|
||||||
|
@ -1122,7 +1134,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
|
"[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
|
||||||
part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
|
part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
|
||||||
part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
|
part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
@ -1143,6 +1155,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
lock (m_AddingAssemblies)
|
lock (m_AddingAssemblies)
|
||||||
{
|
{
|
||||||
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
|
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
|
||||||
|
|
||||||
if (!m_AddingAssemblies.ContainsKey(assembly)) {
|
if (!m_AddingAssemblies.ContainsKey(assembly)) {
|
||||||
m_AddingAssemblies[assembly] = 1;
|
m_AddingAssemblies[assembly] = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1303,7 +1316,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
startParam, postOnRez,
|
startParam, postOnRez,
|
||||||
m_MaxScriptQueue);
|
m_MaxScriptQueue);
|
||||||
|
|
||||||
instance.Load(m_AppDomains[appDomain], assembly, stateSource);
|
if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
|
||||||
|
return false;
|
||||||
|
|
||||||
// if (DebugLevel >= 1)
|
// if (DebugLevel >= 1)
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
|
|
|
@ -2442,6 +2442,7 @@
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
|
<Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.Instance"/>
|
<Reference name="OpenSim.Region.ScriptEngine.Shared.Instance"/>
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
|
<Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
|
||||||
|
<Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/>
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.XEngine.Api.Runtime"/>
|
<Reference name="OpenSim.Region.ScriptEngine.XEngine.Api.Runtime"/>
|
||||||
<Reference name="SmartThreadPool"/>
|
<Reference name="SmartThreadPool"/>
|
||||||
<Reference name="Nini" path="../../../../bin/"/>
|
<Reference name="Nini" path="../../../../bin/"/>
|
||||||
|
|
Loading…
Reference in New Issue