From 01f70de2ea562f78991084be01a83295f8f2be0b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 20 Feb 2009 14:04:29 +0000 Subject: * Consistently lock part.TaskInventory as pointed out in http://opensimulator.org/mantis/view.php?id=3159 * Not locking causes enumeration exceptions as described in this matis * part.TaskInventory needs to be locked for every access as it's a dictionary * Extra locking will hopefully not cause any major issues - in places where the enumeration of the dictionary performs other lock or long running operations, the dictionary is cloned instead --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 96c1698..20e70d0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -231,9 +231,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_stateSource = stateSource; m_postOnRez = postOnRez; - if (part != null && part.TaskInventory.ContainsKey(m_ItemID)) + if (part != null) { - m_thisScriptTask = part.TaskInventory[m_ItemID]; + lock (part.TaskInventory) + { + if (part.TaskInventory.ContainsKey(m_ItemID)) + { + m_thisScriptTask = part.TaskInventory[m_ItemID]; + } + } } ApiManager am = new ApiManager(); @@ -399,15 +405,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private void ReleaseControls() { - SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); - if (part != null && part.TaskInventory.ContainsKey(m_ItemID)) + SceneObjectPart part = m_Engine.World.GetSceneObjectPart(m_LocalID); + + if (part != null) { - UUID permsGranter = part.TaskInventory[m_ItemID].PermsGranter; - int permsMask = part.TaskInventory[m_ItemID].PermsMask; + int permsMask; + UUID permsGranter; + lock (part.TaskInventory) + { + if (!part.TaskInventory.ContainsKey(m_ItemID)) + return; + + permsGranter = part.TaskInventory[m_ItemID].PermsGranter; + permsMask = part.TaskInventory[m_ItemID].PermsMask; + } if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { - ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter); if (presence != null) presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); -- cgit v1.1