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 | |
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 '')
6 files changed, 111 insertions, 67 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs index e4ca635..a7fa502 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs | |||
@@ -34,7 +34,36 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
34 | { | 34 | { |
35 | public interface ICompiler | 35 | public interface ICompiler |
36 | { | 36 | { |
37 | void PerformScriptCompile(string source, string asset, UUID ownerID, out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); | 37 | /// <summary> |
38 | /// Performs the script compile. | ||
39 | /// </summary> | ||
40 | /// <param name="Script"></param> | ||
41 | /// <param name="asset"></param> | ||
42 | /// <param name="ownerUUID"></param> | ||
43 | /// <param name="alwaysRecompile"> | ||
44 | /// If set to true then always recompile the script, even if we have a DLL already cached. | ||
45 | /// </param> | ||
46 | /// <param name="assembly"></param> | ||
47 | /// <param name="linemap"></param> | ||
48 | void PerformScriptCompile( | ||
49 | string source, string asset, UUID ownerID, | ||
50 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); | ||
51 | |||
52 | /// <summary> | ||
53 | /// Performs the script compile. | ||
54 | /// </summary> | ||
55 | /// <param name="Script"></param> | ||
56 | /// <param name="asset"></param> | ||
57 | /// <param name="ownerUUID"></param> | ||
58 | /// <param name="alwaysRecompile"> | ||
59 | /// If set to true then always recompile the script, even if we have a DLL already cached. | ||
60 | /// </param> | ||
61 | /// <param name="assembly"></param> | ||
62 | /// <param name="linemap"></param> | ||
63 | void PerformScriptCompile( | ||
64 | string source, string asset, UUID ownerID, bool alwaysRecompile, | ||
65 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); | ||
66 | |||
38 | string[] GetWarnings(); | 67 | string[] GetWarnings(); |
39 | } | 68 | } |
40 | } | 69 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index f874de2..98658b6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -284,12 +284,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
284 | return GetCompilerOutput(assetID.ToString()); | 284 | return GetCompilerOutput(assetID.ToString()); |
285 | } | 285 | } |
286 | 286 | ||
287 | /// <summary> | 287 | public void PerformScriptCompile( |
288 | /// Converts script from LSL to CS and calls CompileFromCSText | 288 | string source, string asset, UUID ownerUUID, |
289 | /// </summary> | 289 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) |
290 | /// <param name="Script">LSL script</param> | 290 | { |
291 | /// <returns>Filename to .dll assembly</returns> | 291 | PerformScriptCompile(source, asset, ownerUUID, false, out assembly, out linemap); |
292 | public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, | 292 | } |
293 | |||
294 | public void PerformScriptCompile( | ||
295 | string source, string asset, UUID ownerUUID, bool alwaysRecompile, | ||
293 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) | 296 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) |
294 | { | 297 | { |
295 | // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); | 298 | // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); |
@@ -303,9 +306,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
303 | 306 | ||
304 | CheckOrCreateScriptsDirectory(); | 307 | CheckOrCreateScriptsDirectory(); |
305 | 308 | ||
306 | // Don't recompile if we already have it | 309 | // Don't recompile if we're not forced to and we already have it |
307 | // Performing 3 file exists tests for every script can still be slow | 310 | // Performing 3 file exists tests for every script can still be slow |
308 | if (File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) | 311 | if (!alwaysRecompile && File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) |
309 | { | 312 | { |
310 | // If we have already read this linemap file, then it will be in our dictionary. | 313 | // If we have already read this linemap file, then it will be in our dictionary. |
311 | // Don't build another copy of the dictionary (saves memory) and certainly | 314 | // Don't build another copy of the dictionary (saves memory) and certainly |
@@ -316,29 +319,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
316 | return; | 319 | return; |
317 | } | 320 | } |
318 | 321 | ||
319 | if (Script == String.Empty) | 322 | if (source == String.Empty) |
320 | { | ||
321 | throw new Exception("Cannot find script assembly and no script text present"); | 323 | throw new Exception("Cannot find script assembly and no script text present"); |
322 | } | ||
323 | 324 | ||
324 | enumCompileType language = DefaultCompileLanguage; | 325 | enumCompileType language = DefaultCompileLanguage; |
325 | 326 | ||
326 | if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) | 327 | if (source.StartsWith("//c#", true, CultureInfo.InvariantCulture)) |
327 | language = enumCompileType.cs; | 328 | language = enumCompileType.cs; |
328 | if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) | 329 | if (source.StartsWith("//vb", true, CultureInfo.InvariantCulture)) |
329 | { | 330 | { |
330 | language = enumCompileType.vb; | 331 | language = enumCompileType.vb; |
331 | // We need to remove //vb, it won't compile with that | 332 | // We need to remove //vb, it won't compile with that |
332 | 333 | ||
333 | Script = Script.Substring(4, Script.Length - 4); | 334 | source = source.Substring(4, source.Length - 4); |
334 | } | 335 | } |
335 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) | 336 | if (source.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) |
336 | language = enumCompileType.lsl; | 337 | language = enumCompileType.lsl; |
337 | 338 | ||
338 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) | 339 | if (source.StartsWith("//js", true, CultureInfo.InvariantCulture)) |
339 | language = enumCompileType.js; | 340 | language = enumCompileType.js; |
340 | 341 | ||
341 | if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) | 342 | if (source.StartsWith("//yp", true, CultureInfo.InvariantCulture)) |
342 | language = enumCompileType.yp; | 343 | language = enumCompileType.yp; |
343 | 344 | ||
344 | // m_log.DebugFormat("[Compiler]: Compile language is {0}", language); | 345 | // m_log.DebugFormat("[Compiler]: Compile language is {0}", language); |
@@ -359,13 +360,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
359 | throw new Exception(errtext); | 360 | throw new Exception(errtext); |
360 | } | 361 | } |
361 | 362 | ||
362 | string compileScript = Script; | 363 | string compileScript = source; |
363 | 364 | ||
364 | if (language == enumCompileType.lsl) | 365 | if (language == enumCompileType.lsl) |
365 | { | 366 | { |
366 | // Its LSL, convert it to C# | 367 | // Its LSL, convert it to C# |
367 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); | 368 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); |
368 | compileScript = LSL_Converter.Convert(Script); | 369 | compileScript = LSL_Converter.Convert(source); |
369 | 370 | ||
370 | // copy converter warnings into our warnings. | 371 | // copy converter warnings into our warnings. |
371 | foreach (string warning in LSL_Converter.GetWarnings()) | 372 | foreach (string warning in LSL_Converter.GetWarnings()) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 938cb2e..388de7f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | |||
@@ -67,8 +67,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
67 | } | 67 | } |
68 | 68 | ||
69 | [SetUp] | 69 | [SetUp] |
70 | public void SetUp() | 70 | public override void SetUp() |
71 | { | 71 | { |
72 | base.SetUp(); | ||
73 | |||
72 | // Create a CSCodeProvider and CompilerParameters. | 74 | // Create a CSCodeProvider and CompilerParameters. |
73 | m_CSCodeProvider = new CSharpCodeProvider(); | 75 | m_CSCodeProvider = new CSharpCodeProvider(); |
74 | m_compilerParameters = new CompilerParameters(); | 76 | m_compilerParameters = new CompilerParameters(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index c5d0752..979c84a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -237,12 +237,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
237 | m_postOnRez = postOnRez; | 237 | m_postOnRez = postOnRez; |
238 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; | 238 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; |
239 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; | 239 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; |
240 | |||
241 | if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op") | ||
242 | { | ||
243 | m_coopTermination = true; | ||
244 | m_coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset); | ||
245 | } | ||
246 | } | 240 | } |
247 | 241 | ||
248 | /// <summary> | 242 | /// <summary> |
@@ -252,54 +246,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
252 | /// <param name='assembly'></param> | 246 | /// <param name='assembly'></param> |
253 | /// <param name='stateSource'></param> | 247 | /// <param name='stateSource'></param> |
254 | /// <returns>false if load failed, true if suceeded</returns> | 248 | /// <returns>false if load failed, true if suceeded</returns> |
255 | public bool Load(AppDomain dom, string assembly, StateSource stateSource) | 249 | public bool Load(AppDomain dom, Assembly scriptAssembly, StateSource stateSource) |
256 | { | 250 | { |
257 | m_Assembly = assembly; | 251 | //m_Assembly = scriptAssembly.CodeBase; |
252 | m_Assembly = scriptAssembly.Location; | ||
258 | m_stateSource = stateSource; | 253 | m_stateSource = stateSource; |
259 | |||
260 | ApiManager am = new ApiManager(); | ||
261 | |||
262 | foreach (string api in am.GetApis()) | ||
263 | { | ||
264 | m_Apis[api] = am.CreateApi(api); | ||
265 | m_Apis[api].Initialize(Engine, Part, ScriptTask, m_coopSleepHandle); | ||
266 | } | ||
267 | 254 | ||
268 | try | 255 | try |
269 | { | 256 | { |
270 | object[] constructorParams; | 257 | object[] constructorParams; |
271 | |||
272 | Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly)); | ||
273 | Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); | 258 | Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); |
274 | 259 | ||
275 | if (scriptType != null) | 260 | if (scriptType != null) |
276 | { | 261 | { |
262 | m_coopTermination = true; | ||
263 | m_coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset); | ||
277 | constructorParams = new object[] { m_coopSleepHandle }; | 264 | constructorParams = new object[] { m_coopSleepHandle }; |
278 | } | 265 | } |
279 | else if (!m_coopTermination) | 266 | else |
280 | { | 267 | { |
268 | m_coopTermination = false; | ||
281 | scriptType = scriptAssembly.GetType("SecondLife.Script"); | 269 | scriptType = scriptAssembly.GetType("SecondLife.Script"); |
282 | constructorParams = null; | 270 | constructorParams = null; |
283 | } | 271 | } |
284 | else | ||
285 | { | ||
286 | m_log.ErrorFormat( | ||
287 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. You must remove all existing {6}* script DLL files before using enabling co-op termination" | ||
288 | + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run" | ||
289 | + " or by deleting these files manually.", | ||
290 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, assembly); | ||
291 | |||
292 | return false; | ||
293 | } | ||
294 | 272 | ||
295 | // m_log.DebugFormat( | 273 | // m_log.DebugFormat( |
296 | // "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}", | 274 | // "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}", |
297 | // scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name); | 275 | // scriptType.FullName, m_Assembly, Engine.World.Name); |
298 | 276 | ||
299 | if (dom != System.AppDomain.CurrentDomain) | 277 | if (dom != System.AppDomain.CurrentDomain) |
300 | m_Script | 278 | m_Script |
301 | = (IScript)dom.CreateInstanceAndUnwrap( | 279 | = (IScript)dom.CreateInstanceAndUnwrap( |
302 | Path.GetFileNameWithoutExtension(assembly), | 280 | Path.GetFileNameWithoutExtension(m_Assembly), |
303 | scriptType.FullName, | 281 | scriptType.FullName, |
304 | false, | 282 | false, |
305 | BindingFlags.Default, | 283 | BindingFlags.Default, |
@@ -327,11 +305,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
327 | { | 305 | { |
328 | m_log.ErrorFormat( | 306 | m_log.ErrorFormat( |
329 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}", | 307 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}", |
330 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, assembly, e.Message, e.StackTrace); | 308 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, m_Assembly, e.Message, e.StackTrace); |
331 | 309 | ||
332 | return false; | 310 | return false; |
333 | } | 311 | } |
334 | 312 | ||
313 | ApiManager am = new ApiManager(); | ||
314 | |||
315 | foreach (string api in am.GetApis()) | ||
316 | { | ||
317 | m_Apis[api] = am.CreateApi(api); | ||
318 | m_Apis[api].Initialize(Engine, Part, ScriptTask, m_coopSleepHandle); | ||
319 | } | ||
320 | |||
335 | try | 321 | try |
336 | { | 322 | { |
337 | foreach (KeyValuePair<string,IScriptApi> kv in m_Apis) | 323 | foreach (KeyValuePair<string,IScriptApi> kv in m_Apis) |
@@ -341,8 +327,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
341 | 327 | ||
342 | // // m_log.Debug("[Script] Script instance created"); | 328 | // // m_log.Debug("[Script] Script instance created"); |
343 | 329 | ||
344 | Part.SetScriptEvents(ItemID, | 330 | Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); |
345 | (int)m_Script.GetStateEventFlags(State)); | ||
346 | } | 331 | } |
347 | catch (Exception e) | 332 | catch (Exception e) |
348 | { | 333 | { |
@@ -355,8 +340,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
355 | 340 | ||
356 | m_SaveState = true; | 341 | m_SaveState = true; |
357 | 342 | ||
358 | string savedState = Path.Combine(Path.GetDirectoryName(assembly), | 343 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), ItemID.ToString() + ".state"); |
359 | ItemID.ToString() + ".state"); | 344 | |
360 | if (File.Exists(savedState)) | 345 | if (File.Exists(savedState)) |
361 | { | 346 | { |
362 | string xml = String.Empty; | 347 | string xml = String.Empty; |
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) |