From 889ce36afa67c521f3e50e4833a894ffd39af490 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 23 Nov 2009 16:02:05 +0100 Subject: Added some [DebuggerNonUserCode] modifiers to functions that throw EventAbortException() to ease debugging on Visual Studio --- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d49..ed3fdbe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -27,6 +27,7 @@ using System; using System.IO; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Runtime.Remoting; using System.Runtime.Remoting.Lifetime; using System.Threading; @@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return true; } + [DebuggerNonUserCode] //Prevents the debugger from farting in this function public void SetState(string state) { if (state == State) @@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new DetectParams[0])); PostEvent(new EventParams("state_entry", new Object[0], new DetectParams[0])); - + throw new EventAbortException(); } @@ -824,6 +826,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new Object[0], new DetectParams[0])); } + [DebuggerNonUserCode] //Stops the VS debugger from farting in this function public void ApiResetScript() { // bool running = Running; -- cgit v1.1 From 247c66b3fe792692468ede6a516d85c6c9852d23 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 23 Nov 2009 20:25:53 +0100 Subject: Swap the locking of m_EventQueue and m_Script to ease locks on script inventory operations --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 234 +++++++++++---------- 1 file changed, 119 insertions(+), 115 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ed3fdbe..063d50f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -640,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// public object EventProcessor() { + + EventParams data = null; + + lock (m_EventQueue) + { lock (m_Script) { - EventParams data = null; - - lock (m_EventQueue) + data = (EventParams) m_EventQueue.Dequeue(); + if (data == null) // Shouldn't happen { - data = (EventParams) m_EventQueue.Dequeue(); - if (data == null) // Shouldn't happen + if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) { - if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) - { - m_CurrentResult = m_Engine.QueueEventHandler(this); - } - else - { - m_CurrentResult = null; - } - return 0; + m_CurrentResult = m_Engine.QueueEventHandler(this); } - - if (data.EventName == "timer") - m_TimerQueued = false; - if (data.EventName == "control") + else { - if (m_ControlEventsInQueue > 0) - m_ControlEventsInQueue--; + m_CurrentResult = null; } - if (data.EventName == "collision") - m_CollisionInQueue = false; + return 0; } - - //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); - m_DetectParams = data.DetectParams; - - if (data.EventName == "state") // Hardcoded state change + if (data.EventName == "timer") + m_TimerQueued = false; + if (data.EventName == "control") { - // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", - // m_PrimName, m_ScriptName, data.Params[0].ToString()); - m_State=data.Params[0].ToString(); - AsyncCommandManager.RemoveScript(m_Engine, - m_LocalID, m_ItemID); + if (m_ControlEventsInQueue > 0) + m_ControlEventsInQueue--; + } + if (data.EventName == "collision") + m_CollisionInQueue = false; + } + } + lock(m_Script) + { + + //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); - SceneObjectPart part = m_Engine.World.GetSceneObjectPart( - m_LocalID); - if (part != null) - { - part.SetScriptEvents(m_ItemID, - (int)m_Script.GetStateEventFlags(State)); - } + m_DetectParams = data.DetectParams; + + if (data.EventName == "state") // Hardcoded state change + { +// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", +// m_PrimName, m_ScriptName, data.Params[0].ToString()); + m_State=data.Params[0].ToString(); + AsyncCommandManager.RemoveScript(m_Engine, + m_LocalID, m_ItemID); + + SceneObjectPart part = m_Engine.World.GetSceneObjectPart( + m_LocalID); + if (part != null) + { + part.SetScriptEvents(m_ItemID, + (int)m_Script.GetStateEventFlags(State)); } - else + } + else + { + if (m_Engine.World.PipeEventsForScript(m_LocalID) || + data.EventName == "control") // Don't freeze avies! { - if (m_Engine.World.PipeEventsForScript(m_LocalID) || - data.EventName == "control") // Don't freeze avies! - { - SceneObjectPart part = m_Engine.World.GetSceneObjectPart( - m_LocalID); - // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", - // m_PrimName, m_ScriptName, data.EventName, m_State); + SceneObjectPart part = m_Engine.World.GetSceneObjectPart( + m_LocalID); + // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", + // m_PrimName, m_ScriptName, data.EventName, m_State); - try - { - m_CurrentEvent = data.EventName; - m_EventStart = DateTime.Now; - m_InEvent = true; + try + { + m_CurrentEvent = data.EventName; + m_EventStart = DateTime.Now; + m_InEvent = true; - m_Script.ExecuteEvent(State, data.EventName, data.Params); + m_Script.ExecuteEvent(State, data.EventName, data.Params); - m_InEvent = false; - m_CurrentEvent = String.Empty; + m_InEvent = false; + m_CurrentEvent = String.Empty; - if (m_SaveState) - { - // This will be the very first event we deliver - // (state_entry) in default state - // + if (m_SaveState) + { + // This will be the very first event we deliver + // (state_entry) in default state + // - SaveState(m_Assembly); + SaveState(m_Assembly); - m_SaveState = false; - } + m_SaveState = false; } - catch (Exception e) - { - // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); - m_InEvent = false; - m_CurrentEvent = String.Empty; + } + catch (Exception e) + { + // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); + m_InEvent = false; + m_CurrentEvent = String.Empty; - if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) - { - try - { - // DISPLAY ERROR INWORLD - string text = FormatException(e); - - if (text.Length > 1000) - text = text.Substring(0, 1000); - m_Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); - } - catch (Exception) - { - } - // catch (Exception e2) // LEGIT: User Scripting - // { - // m_log.Error("[SCRIPT]: "+ - // "Error displaying error in-world: " + - // e2.ToString()); - // m_log.Error("[SCRIPT]: " + - // "Errormessage: Error compiling script:\r\n" + - // e.ToString()); - // } - } - else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) + if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) + { + try { - m_InSelfDelete = true; - if (part != null && part.ParentGroup != null) - m_Engine.World.DeleteSceneObject(part.ParentGroup, false); + // DISPLAY ERROR INWORLD + string text = FormatException(e); + + if (text.Length > 1000) + text = text.Substring(0, 1000); + m_Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + part.AbsolutePosition, + part.Name, part.UUID, false); } - else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) + catch (Exception) { - m_InSelfDelete = true; - if (part != null && part.ParentGroup != null) - part.Inventory.RemoveInventoryItem(m_ItemID); } + // catch (Exception e2) // LEGIT: User Scripting + // { + // m_log.Error("[SCRIPT]: "+ + // "Error displaying error in-world: " + + // e2.ToString()); + // m_log.Error("[SCRIPT]: " + + // "Errormessage: Error compiling script:\r\n" + + // 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, false); + } + else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) + { + m_InSelfDelete = true; + if (part != null && part.ParentGroup != null) + part.Inventory.RemoveInventoryItem(m_ItemID); } } } + } - lock (m_EventQueue) + lock (m_EventQueue) + { + if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) { - if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) - { - m_CurrentResult = m_Engine.QueueEventHandler(this); - } - else - { - m_CurrentResult = null; - } + m_CurrentResult = m_Engine.QueueEventHandler(this); + } + else + { + m_CurrentResult = null; } + } - m_DetectParams = null; + m_DetectParams = null; - return 0; - } + return 0; + } } public int EventTime() -- cgit v1.1 From d1147136946daf14724183b3191119be44ff8b16 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 18:02:12 +0100 Subject: Drop all locking of part.TaskInventory in favour of a ReaderWriterLockSlim lock handler. This gives us: - Faster prim inventory actions. Multiple threads can read at once. - Fixes the known prim inventory thread locks - In the event of a thread lock occurring, it will usually self heal after sixty seconds with an error message in the console --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 063d50f..0f4a9ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -238,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (part != null) { - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + if (part.TaskInventory.ContainsKey(m_ItemID)) { - if (part.TaskInventory.ContainsKey(m_ItemID)) - { - m_thisScriptTask = part.TaskInventory[m_ItemID]; - } + m_thisScriptTask = part.TaskInventory[m_ItemID]; } + part.TaskInventory.LockItemsForRead(false); } ApiManager am = new ApiManager(); @@ -429,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { int permsMask; UUID permsGranter; - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + if (!part.TaskInventory.ContainsKey(m_ItemID)) { - if (!part.TaskInventory.ContainsKey(m_ItemID)) - return; - - permsGranter = part.TaskInventory[m_ItemID].PermsGranter; - permsMask = part.TaskInventory[m_ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); + return; } + permsGranter = part.TaskInventory[m_ItemID].PermsGranter; + permsMask = part.TaskInventory[m_ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { -- cgit v1.1 From 9d63f90467dbc60622a49f564a56fdd20de90f51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 17:03:09 +0000 Subject: Remove the old (Remoting) region crossing code. Fix the new code to pass script state and assembly again properly. Reintroduce respecting tht TrustBinaries flag. Changes the interregion protocol! No version bump because it was broken anyway, so with a version mismatch it will simply stay broken, but not crash. Region corssing still doesn't work because there is still monkey business with both rezzed prims being pushed across a border and attached prims when walking across a border. Teleport is untested by may work. --- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d49..5c5d57e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -1011,10 +1011,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { get { return m_RegionID; } } - - public bool CanBeDeleted() - { - return true; - } } } -- cgit v1.1