aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-23 02:28:27 +0000
committerJustin Clark-Casey (justincc)2013-01-23 02:36:43 +0000
commitcf168194e5968c1fab33266bdbb57465f303860b (patch)
tree7fbf7f668bd48a9831df7eefdf47c09baa47a522 /OpenSim/Region/ScriptEngine/Shared/Instance
parentAdd co-op termination regression test for infinite recursive manual call on e... (diff)
downloadopensim-SC_OLD-cf168194e5968c1fab33266bdbb57465f303860b.zip
opensim-SC_OLD-cf168194e5968c1fab33266bdbb57465f303860b.tar.gz
opensim-SC_OLD-cf168194e5968c1fab33266bdbb57465f303860b.tar.bz2
opensim-SC_OLD-cf168194e5968c1fab33266bdbb57465f303860b.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs48
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs2
2 files changed, 41 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index e6ec0e1..4cfcb75 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -251,7 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
251 /// <param name='dom'></param> 251 /// <param name='dom'></param>
252 /// <param name='assembly'></param> 252 /// <param name='assembly'></param>
253 /// <param name='stateSource'></param> 253 /// <param name='stateSource'></param>
254 public void Load(AppDomain dom, string assembly, StateSource stateSource) 254 /// <returns>false if load failed, true if suceeded</returns>
255 public bool Load(AppDomain dom, string assembly, StateSource stateSource)
255 { 256 {
256 m_Assembly = assembly; 257 m_Assembly = assembly;
257 m_stateSource = stateSource; 258 m_stateSource = stateSource;
@@ -266,26 +267,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
266 267
267 try 268 try
268 { 269 {
270 object[] constructorParams;
271
272 Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly));
273 Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript");
274
275 if (scriptType != null)
276 {
277 constructorParams = new object[] { m_coopSleepHandle };
278 }
279 else if (!m_coopTermination)
280 {
281 scriptType = scriptAssembly.GetType("SecondLife.Script");
282 constructorParams = null;
283 }
284 else
285 {
286 m_log.ErrorFormat(
287 "[SCRIPT INSTANCE]: You must remove all existing script DLLs before using enabling co-op termination"
288 + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run"
289 + " or by deleting all *.dll* files in the relevant bin/ScriptEngines/<region-id>/ directory");
290
291 return false;
292 }
293
294// m_log.DebugFormat(
295// "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}",
296// scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name);
297
269 if (dom != System.AppDomain.CurrentDomain) 298 if (dom != System.AppDomain.CurrentDomain)
270 m_Script 299 m_Script
271 = (IScript)dom.CreateInstanceAndUnwrap( 300 = (IScript)dom.CreateInstanceAndUnwrap(
272 Path.GetFileNameWithoutExtension(assembly), 301 Path.GetFileNameWithoutExtension(assembly),
273 "SecondLife.Script", 302 scriptType.FullName,
274 false, 303 false,
275 BindingFlags.Default, 304 BindingFlags.Default,
276 null, 305 null,
277 new object[] { m_coopSleepHandle }, 306 constructorParams,
278 null,
279 null, 307 null,
280 null); 308 null);
281 else 309 else
282 m_Script 310 m_Script
283 = (IScript)Assembly.Load(Path.GetFileNameWithoutExtension(assembly)).CreateInstance( 311 = (IScript)scriptAssembly.CreateInstance(
284 "SecondLife.Script", 312 scriptType.FullName,
285 false, 313 false,
286 BindingFlags.Default, 314 BindingFlags.Default,
287 null, 315 null,
288 new object[] { m_coopSleepHandle }, 316 constructorParams,
289 null, 317 null,
290 null); 318 null);
291 319
@@ -298,6 +326,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
298 m_log.ErrorFormat( 326 m_log.ErrorFormat(
299 "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", 327 "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}",
300 assembly, e.Message, e.StackTrace); 328 assembly, e.Message, e.StackTrace);
329
330 return false;
301 } 331 }
302 332
303 try 333 try
@@ -318,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
318 "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", 348 "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}",
319 assembly, e.Message, e.StackTrace); 349 assembly, e.Message, e.StackTrace);
320 350
321 return; 351 return false;
322 } 352 }
323 353
324 m_SaveState = true; 354 m_SaveState = true;
@@ -390,6 +420,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
390// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); 420// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
391 421
392// } 422// }
423
424 return true;
393 } 425 }
394 426
395 public void Init() 427 public void Init()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
index bd882f9..52d75a0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
@@ -245,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
245 public void TestStopOnInfiniteJumpLoop() 245 public void TestStopOnInfiniteJumpLoop()
246 { 246 {
247 TestHelpers.InMethod(); 247 TestHelpers.InMethod();
248// TestHelpers.EnableLogging(); 248 TestHelpers.EnableLogging();
249 249
250 string script = 250 string script =
251@"default 251@"default