diff options
author | Melanie | 2013-01-24 00:25:08 +0000 |
---|---|---|
committer | Melanie | 2013-01-24 00:25:08 +0000 |
commit | be4c8c4931637b7b0849d12c634599c702483364 (patch) | |
tree | 9a49626efcc10f1272b37176616a41476b044045 /OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' into cooptermination (diff) | |
download | opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.zip opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.tar.gz opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.tar.bz2 opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 98 |
1 files changed, 74 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index a869a6a..891e453 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -252,7 +252,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
252 | /// <param name='dom'></param> | 252 | /// <param name='dom'></param> |
253 | /// <param name='assembly'></param> | 253 | /// <param name='assembly'></param> |
254 | /// <param name='stateSource'></param> | 254 | /// <param name='stateSource'></param> |
255 | public void Load(AppDomain dom, string assembly, StateSource stateSource) | 255 | /// <returns>false if load failed, true if suceeded</returns> |
256 | public bool Load(AppDomain dom, string assembly, StateSource stateSource) | ||
256 | { | 257 | { |
257 | m_Assembly = assembly; | 258 | m_Assembly = assembly; |
258 | m_stateSource = stateSource; | 259 | m_stateSource = stateSource; |
@@ -267,14 +268,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
267 | 268 | ||
268 | try | 269 | try |
269 | { | 270 | { |
271 | object[] constructorParams; | ||
272 | |||
273 | Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly)); | ||
274 | Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); | ||
275 | |||
276 | if (scriptType != null) | ||
277 | { | ||
278 | constructorParams = new object[] { m_coopSleepHandle }; | ||
279 | } | ||
280 | else if (!m_coopTermination) | ||
281 | { | ||
282 | scriptType = scriptAssembly.GetType("SecondLife.Script"); | ||
283 | constructorParams = null; | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | m_log.ErrorFormat( | ||
288 | "[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" | ||
289 | + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run" | ||
290 | + " or by deleting these files manually.", | ||
291 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, assembly); | ||
292 | |||
293 | return false; | ||
294 | } | ||
295 | |||
296 | // m_log.DebugFormat( | ||
297 | // "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}", | ||
298 | // scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name); | ||
299 | |||
270 | if (dom != System.AppDomain.CurrentDomain) | 300 | if (dom != System.AppDomain.CurrentDomain) |
271 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( | 301 | m_Script |
302 | = (IScript)dom.CreateInstanceAndUnwrap( | ||
272 | Path.GetFileNameWithoutExtension(assembly), | 303 | Path.GetFileNameWithoutExtension(assembly), |
273 | "SecondLife.Script"); | 304 | scriptType.FullName, |
305 | false, | ||
306 | BindingFlags.Default, | ||
307 | null, | ||
308 | constructorParams, | ||
309 | null, | ||
310 | null); | ||
274 | else | 311 | else |
275 | m_Script = (IScript)Assembly.Load( | 312 | m_Script |
276 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( | 313 | = (IScript)scriptAssembly.CreateInstance( |
277 | "SecondLife.Script"); | 314 | scriptType.FullName, |
315 | false, | ||
316 | BindingFlags.Default, | ||
317 | null, | ||
318 | constructorParams, | ||
319 | null, | ||
320 | null); | ||
278 | 321 | ||
279 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 322 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
280 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 323 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
@@ -283,8 +326,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
283 | catch (Exception e) | 326 | catch (Exception e) |
284 | { | 327 | { |
285 | m_log.ErrorFormat( | 328 | m_log.ErrorFormat( |
286 | "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", | 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}", |
287 | assembly, e.Message, e.StackTrace); | 330 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, assembly, e.Message, e.StackTrace); |
331 | |||
332 | return false; | ||
288 | } | 333 | } |
289 | 334 | ||
290 | try | 335 | try |
@@ -302,10 +347,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
302 | catch (Exception e) | 347 | catch (Exception e) |
303 | { | 348 | { |
304 | m_log.ErrorFormat( | 349 | m_log.ErrorFormat( |
305 | "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", | 350 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error initializing script instance. Exception {6}{7}", |
306 | assembly, e.Message, e.StackTrace); | 351 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, e.Message, e.StackTrace); |
307 | 352 | ||
308 | return; | 353 | return false; |
309 | } | 354 | } |
310 | 355 | ||
311 | m_SaveState = true; | 356 | m_SaveState = true; |
@@ -358,15 +403,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
358 | else | 403 | else |
359 | { | 404 | { |
360 | m_log.WarnFormat( | 405 | m_log.WarnFormat( |
361 | "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). Memory limit exceeded", | 406 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.", |
362 | savedState, ScriptName, ItemID, PrimName, ObjectID, assembly); | 407 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); |
363 | } | 408 | } |
364 | } | 409 | } |
365 | catch (Exception e) | 410 | catch (Exception e) |
366 | { | 411 | { |
367 | m_log.ErrorFormat( | 412 | m_log.ErrorFormat( |
368 | "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). XML is {6}. Exception {7}{8}", | 413 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. XML is {7}. Exception {8}{9}", |
369 | savedState, ScriptName, ItemID, PrimName, ObjectID, assembly, xml, e.Message, e.StackTrace); | 414 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState, xml, e.Message, e.StackTrace); |
370 | } | 415 | } |
371 | } | 416 | } |
372 | // else | 417 | // else |
@@ -377,6 +422,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
377 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); | 422 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); |
378 | 423 | ||
379 | // } | 424 | // } |
425 | |||
426 | return true; | ||
380 | } | 427 | } |
381 | 428 | ||
382 | public void Init() | 429 | public void Init() |
@@ -560,9 +607,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
560 | } | 607 | } |
561 | else | 608 | else |
562 | { | 609 | { |
563 | m_log.DebugFormat( | 610 | if (DebugLevel >= 1) |
564 | "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}", | 611 | m_log.DebugFormat( |
565 | ScriptName, ItemID, PrimName, ObjectID); | 612 | "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}", |
613 | ScriptName, ItemID, PrimName, ObjectID); | ||
566 | 614 | ||
567 | // This will terminate the event on next handle check by the script. | 615 | // This will terminate the event on next handle check by the script. |
568 | m_coopSleepHandle.Set(); | 616 | m_coopSleepHandle.Set(); |
@@ -571,9 +619,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
571 | // checking is implemented. May want to allow a shorter timeout option later. | 619 | // checking is implemented. May want to allow a shorter timeout option later. |
572 | if (workItem.Wait(TimeSpan.MaxValue)) | 620 | if (workItem.Wait(TimeSpan.MaxValue)) |
573 | { | 621 | { |
574 | m_log.DebugFormat( | 622 | if (DebugLevel >= 1) |
575 | "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}", | 623 | m_log.DebugFormat( |
576 | ScriptName, ItemID, PrimName, ObjectID); | 624 | "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}", |
625 | ScriptName, ItemID, PrimName, ObjectID); | ||
577 | 626 | ||
578 | return true; | 627 | return true; |
579 | } | 628 | } |
@@ -894,9 +943,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
894 | } | 943 | } |
895 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) | 944 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) |
896 | { | 945 | { |
897 | m_log.DebugFormat( | 946 | if (DebugLevel >= 1) |
898 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", | 947 | m_log.DebugFormat( |
899 | PrimName, ScriptName, data.EventName, State); | 948 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", |
949 | PrimName, ScriptName, data.EventName, State); | ||
900 | } | 950 | } |
901 | } | 951 | } |
902 | } | 952 | } |