diff options
author | Justin Clark-Casey (justincc) | 2014-07-11 00:03:02 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-07-11 00:03:02 +0100 |
commit | d7b92604963c7ecbddf76db37eabb84ed36fcfde (patch) | |
tree | 0f75eca56190522c477f2e53574e47ce9019f26b /OpenSim/Region/ScriptEngine/XEngine | |
parent | refactor: use existing Compiler.CreateScriptsDirectory() (renamed to CheckOrC... (diff) | |
download | opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.zip opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.tar.gz opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.tar.bz2 opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 45 |
2 files changed, 37 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs index 5abfe9a..bafcdd8 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs | |||
@@ -87,7 +87,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
87 | public void TestCompileAndStartScript() | 87 | public void TestCompileAndStartScript() |
88 | { | 88 | { |
89 | TestHelpers.InMethod(); | 89 | TestHelpers.InMethod(); |
90 | // log4net.Config.XmlConfigurator.Configure(); | 90 | TestHelpers.EnableLogging(); |
91 | 91 | ||
92 | UUID userId = TestHelpers.ParseTail(0x1); | 92 | UUID userId = TestHelpers.ParseTail(0x1); |
93 | // UUID objectId = TestHelpers.ParseTail(0x100); | 93 | // UUID objectId = TestHelpers.ParseTail(0x100); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b261b9f..7cb4862 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -86,6 +86,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
86 | /// </summary> | 86 | /// </summary> |
87 | private int m_StartDelay; | 87 | private int m_StartDelay; |
88 | 88 | ||
89 | private bool m_coopTermination; | ||
90 | |||
89 | private int m_IdleTimeout; | 91 | private int m_IdleTimeout; |
90 | private int m_StackSize; | 92 | private int m_StackSize; |
91 | private int m_SleepTime; | 93 | private int m_SleepTime; |
@@ -246,6 +248,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
246 | 248 | ||
247 | if (rawScriptStopStrategy == "co-op") | 249 | if (rawScriptStopStrategy == "co-op") |
248 | { | 250 | { |
251 | m_coopTermination = true; | ||
249 | ScriptClassName = "XEngineScript"; | 252 | ScriptClassName = "XEngineScript"; |
250 | ScriptBaseClassName = typeof(XEngineScriptBase).FullName; | 253 | ScriptBaseClassName = typeof(XEngineScriptBase).FullName; |
251 | ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); | 254 | ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); |
@@ -1139,7 +1142,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1139 | 1142 | ||
1140 | ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); | 1143 | ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); |
1141 | 1144 | ||
1142 | string assembly = ""; | 1145 | string assemblyPath = ""; |
1143 | 1146 | ||
1144 | Culture.SetCurrentCulture(); | 1147 | Culture.SetCurrentCulture(); |
1145 | 1148 | ||
@@ -1151,12 +1154,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1151 | { | 1154 | { |
1152 | lock (m_AddingAssemblies) | 1155 | lock (m_AddingAssemblies) |
1153 | { | 1156 | { |
1154 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); | 1157 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assemblyPath, out linemap); |
1155 | 1158 | ||
1156 | if (!m_AddingAssemblies.ContainsKey(assembly)) { | 1159 | if (!m_AddingAssemblies.ContainsKey(assemblyPath)) { |
1157 | m_AddingAssemblies[assembly] = 1; | 1160 | m_AddingAssemblies[assemblyPath] = 1; |
1158 | } else { | 1161 | } else { |
1159 | m_AddingAssemblies[assembly]++; | 1162 | m_AddingAssemblies[assemblyPath]++; |
1160 | } | 1163 | } |
1161 | } | 1164 | } |
1162 | 1165 | ||
@@ -1301,19 +1304,43 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1301 | m_ScriptFailCount++; | 1304 | m_ScriptFailCount++; |
1302 | lock (m_AddingAssemblies) | 1305 | lock (m_AddingAssemblies) |
1303 | { | 1306 | { |
1304 | m_AddingAssemblies[assembly]--; | 1307 | m_AddingAssemblies[assemblyPath]--; |
1305 | } | 1308 | } |
1306 | return false; | 1309 | return false; |
1307 | } | 1310 | } |
1308 | } | 1311 | } |
1309 | m_DomainScripts[appDomain].Add(itemID); | 1312 | m_DomainScripts[appDomain].Add(itemID); |
1310 | 1313 | ||
1314 | Assembly scriptAssembly = m_AppDomains[appDomain].Load(Path.GetFileNameWithoutExtension(assemblyPath)); | ||
1315 | bool recompile = false; | ||
1316 | |||
1317 | if (m_coopTermination) | ||
1318 | { | ||
1319 | Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); | ||
1320 | |||
1321 | if (scriptType == null) | ||
1322 | recompile = true; | ||
1323 | } | ||
1324 | else | ||
1325 | { | ||
1326 | Type scriptType = scriptAssembly.GetType("SecondLife.Script"); | ||
1327 | |||
1328 | if (scriptType == null) | ||
1329 | recompile = true; | ||
1330 | } | ||
1331 | |||
1332 | // If we are loading all scripts into the same AppDomain, then we can't reload the DLL in this | ||
1333 | // simulator session if the script halt strategy has been changed. Instead, we'll continue with | ||
1334 | // the existing DLL and the new one will be used in the next simulator session. | ||
1335 | if (recompile) | ||
1336 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, true, out assemblyPath, out linemap); | ||
1337 | |||
1311 | instance = new ScriptInstance(this, part, | 1338 | instance = new ScriptInstance(this, part, |
1312 | item, | 1339 | item, |
1313 | startParam, postOnRez, | 1340 | startParam, postOnRez, |
1314 | m_MaxScriptQueue); | 1341 | m_MaxScriptQueue); |
1315 | 1342 | ||
1316 | if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) | 1343 | if (!instance.Load(m_AppDomains[appDomain], scriptAssembly, stateSource)) |
1317 | return false; | 1344 | return false; |
1318 | 1345 | ||
1319 | // if (DebugLevel >= 1) | 1346 | // if (DebugLevel >= 1) |
@@ -1345,11 +1372,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1345 | } | 1372 | } |
1346 | 1373 | ||
1347 | if (!m_Assemblies.ContainsKey(assetID)) | 1374 | if (!m_Assemblies.ContainsKey(assetID)) |
1348 | m_Assemblies[assetID] = assembly; | 1375 | m_Assemblies[assetID] = assemblyPath; |
1349 | 1376 | ||
1350 | lock (m_AddingAssemblies) | 1377 | lock (m_AddingAssemblies) |
1351 | { | 1378 | { |
1352 | m_AddingAssemblies[assembly]--; | 1379 | m_AddingAssemblies[assemblyPath]--; |
1353 | } | 1380 | } |
1354 | 1381 | ||
1355 | if (instance != null) | 1382 | if (instance != null) |