If [XEngine] ScriptStopStrategy is changed between abort and co-op, for the existing session use the previous strategy for that script rather than not starting the script at all.

We have to do this since we can't unload existing DLLs if they're all in the same AppDomain.
But we can still update the underlying DLL which will be used in the next simulator session.
This commit is contained in:
Justin Clark-Casey (justincc)
2014-07-11 00:03:02 +01:00
parent 6d3b409af2
commit d7b9260496
6 changed files with 112 additions and 68 deletions

View File

@@ -87,7 +87,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
public void TestCompileAndStartScript()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
// UUID objectId = TestHelpers.ParseTail(0x100);

View File

@@ -86,6 +86,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
/// </summary>
private int m_StartDelay;
private bool m_coopTermination;
private int m_IdleTimeout;
private int m_StackSize;
private int m_SleepTime;
@@ -246,6 +248,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (rawScriptStopStrategy == "co-op")
{
m_coopTermination = true;
ScriptClassName = "XEngineScript";
ScriptBaseClassName = typeof(XEngineScriptBase).FullName;
ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters();
@@ -1139,7 +1142,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
string assembly = "";
string assemblyPath = "";
Culture.SetCurrentCulture();
@@ -1151,12 +1154,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
lock (m_AddingAssemblies)
{
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assemblyPath, out linemap);
if (!m_AddingAssemblies.ContainsKey(assembly)) {
m_AddingAssemblies[assembly] = 1;
if (!m_AddingAssemblies.ContainsKey(assemblyPath)) {
m_AddingAssemblies[assemblyPath] = 1;
} else {
m_AddingAssemblies[assembly]++;
m_AddingAssemblies[assemblyPath]++;
}
}
@@ -1301,19 +1304,43 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_ScriptFailCount++;
lock (m_AddingAssemblies)
{
m_AddingAssemblies[assembly]--;
m_AddingAssemblies[assemblyPath]--;
}
return false;
}
}
m_DomainScripts[appDomain].Add(itemID);
Assembly scriptAssembly = m_AppDomains[appDomain].Load(Path.GetFileNameWithoutExtension(assemblyPath));
bool recompile = false;
if (m_coopTermination)
{
Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript");
if (scriptType == null)
recompile = true;
}
else
{
Type scriptType = scriptAssembly.GetType("SecondLife.Script");
if (scriptType == null)
recompile = true;
}
// If we are loading all scripts into the same AppDomain, then we can't reload the DLL in this
// simulator session if the script halt strategy has been changed. Instead, we'll continue with
// the existing DLL and the new one will be used in the next simulator session.
if (recompile)
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, true, out assemblyPath, out linemap);
instance = new ScriptInstance(this, part,
item,
startParam, postOnRez,
m_MaxScriptQueue);
if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
if (!instance.Load(m_AppDomains[appDomain], scriptAssembly, stateSource))
return false;
// if (DebugLevel >= 1)
@@ -1345,11 +1372,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assembly;
m_Assemblies[assetID] = assemblyPath;
lock (m_AddingAssemblies)
{
m_AddingAssemblies[assembly]--;
m_AddingAssemblies[assemblyPath]--;
}
if (instance != null)