From e992ca025571a891333a57012c2cd4419b6581e5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 15:39:53 -0700 Subject: Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 42 ++++++++++++---------- .../Avatar/InstantMessage/PresenceModule.cs | 11 +++--- .../Inventory/Transfer/InventoryTransferModule.cs | 15 ++++---- 3 files changed, 37 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fc7d63a..4abad81 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -442,42 +442,46 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) { - ScenePresence returnAgent = null; + List scenes = null; lock (m_scenes) + scenes = new List(m_scenes.Values); + + ScenePresence returnAgent = null; + ScenePresence queryagent = null; + foreach (Scene scene in scenes) { - ScenePresence queryagent = null; - foreach (Scene scene in m_scenes.Values) + queryagent = scene.GetScenePresence(AgentID); + if (queryagent != null) { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) + if (!queryagent.IsChildAgent) { - if (!queryagent.IsChildAgent) - { - returnAgent = queryagent; - break; - } + returnAgent = queryagent; + break; } } } + return returnAgent; } private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) { - ScenePresence returnAgent = null; + List scenes = null; lock (m_scenes) + scenes = new List(m_scenes.Values); + + ScenePresence returnAgent = null; + ScenePresence queryagent = null; + foreach (Scene scene in m_scenes.Values) { - ScenePresence queryagent = null; - foreach (Scene scene in m_scenes.Values) + queryagent = scene.GetScenePresence(AgentID); + if (queryagent != null) { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) - { - returnAgent = queryagent; - break; - } + returnAgent = queryagent; + break; } } + return returnAgent; } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index ad05bab..42dd7ff 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -290,13 +290,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // get the agent. This should work every time, as we just got a packet from it ScenePresence agent = null; + List scenes = null; lock (m_Scenes) + scenes = new List(m_Scenes); + + foreach (Scene scene in scenes) { - foreach (Scene scene in m_Scenes) - { - agent = scene.GetScenePresence(agentID); - if (agent != null) break; - } + agent = scene.GetScenePresence(agentID); + if (agent != null) break; } // just to be paranoid... diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..e6e0483 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -111,16 +111,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private Scene FindClientScene(UUID agentId) { + List scenes = null; lock (m_Scenelist) + scenes = new List(m_Scenelist); + + foreach (Scene scene in scenes) { - foreach (Scene scene in m_Scenelist) + ScenePresence presence = scene.GetScenePresence(agentId); + if (presence != null) { - ScenePresence presence = scene.GetScenePresence(agentId); - if (presence != null) - { - if (!presence.IsChildAgent) - return scene; - } + if (!presence.IsChildAgent) + return scene; } } return null; -- cgit v1.1