From 746c6fb1a285134b68176d39fe28c90fe861fe2a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 12 Jul 2008 00:06:45 +0000 Subject: Patch #9141 (Mantis #1655) Untangles llDie handling in XEngine, which resulted in a thread being aborted while executing inside of Scene. --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 14 ++++++++++++++ OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 ++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4bf3e93..3fbe257 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -637,7 +637,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llDie() { m_host.AddScriptLPS(1); - World.DeleteSceneObject(m_host.ParentGroup); + throw new SelfDeleteException(); } public double llGround(LSL_Types.Vector3 offset) diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 28a2173..cd1f2c5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -52,6 +52,20 @@ namespace OpenSim.Region.ScriptEngine.Shared } } + [Serializable] + public class SelfDeleteException : Exception + { + public SelfDeleteException() + { + } + + protected SelfDeleteException( + SerializationInfo info, + StreamingContext context) + { + } + } + public class DetectParams { public DetectParams() diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 6372247..9f67dc1 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -874,6 +874,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private string m_Assembly; private int m_StartParam = 0; private string m_CurrentEvent = String.Empty; + private bool m_InSelfDelete = false; private Dictionary m_Apis = new Dictionary(); @@ -1190,7 +1191,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (result == null) return true; - result.Abort(); + if(!m_InSelfDelete) + result.Abort(); lock (m_EventQueue) { @@ -1298,7 +1300,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_InEvent = false; m_CurrentEvent = String.Empty; - if (!(e is TargetInvocationException) || !(e.InnerException is EventAbortException)) + if (!(e is TargetInvocationException) || (!(e.InnerException is EventAbortException) && (!(e.InnerException is SelfDeleteException)))) { if (e is System.Threading.ThreadAbortException) { @@ -1340,6 +1342,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine e.ToString()); } } + else if((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) + { + m_InSelfDelete = true; + if(part != null && part.ParentGroup != null) + m_Engine.World.DeleteSceneObject(part.ParentGroup); + } } } -- cgit v1.1