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. --- .../Scripting/EMailModules/EmailModule.cs | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting/EMailModules') diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 83f004d..f9f01fe 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -198,19 +198,20 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules private SceneObjectPart findPrim(UUID objectID, out string ObjectRegionName) { + List scenes = null; lock (m_Scenes) + scenes = new List(m_Scenes.Values); + + foreach (Scene s in scenes) { - foreach (Scene s in m_Scenes.Values) + SceneObjectPart part = s.GetSceneObjectPart(objectID); + if (part != null) { - SceneObjectPart part = s.GetSceneObjectPart(objectID); - if (part != null) - { - ObjectRegionName = s.RegionInfo.RegionName; - uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); - uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); - ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; - return part; - } + ObjectRegionName = s.RegionInfo.RegionName; + uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); + uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); + ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; + return part; } } ObjectRegionName = string.Empty; @@ -363,6 +364,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules public Email GetNextEmail(UUID objectID, string sender, string subject) { List queue = null; + List removal = new List(); lock (m_LastGetEmailCall) { @@ -375,7 +377,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules // Hopefully this isn't too time consuming. If it is, we can always push it into a worker thread. DateTime now = DateTime.Now; - List removal = new List(); foreach (UUID uuid in m_LastGetEmailCall.Keys) { if ((now - m_LastGetEmailCall[uuid]) > m_QueueTimeout) @@ -383,15 +384,15 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules removal.Add(uuid); } } + } - foreach (UUID remove in removal) - { + foreach (UUID remove in removal) + { + lock (m_LastGetEmailCall) m_LastGetEmailCall.Remove(remove); - lock (m_MailQueues) - { - m_MailQueues.Remove(remove); - } - } + + lock (m_MailQueues) + m_MailQueues.Remove(remove); } lock (m_MailQueues) -- cgit v1.1