From 89d23a1fa23cb191e7ebde047311adcadf3b2e45 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Oct 2009 01:45:49 +0100 Subject: Revert "Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed." This reverts commit e992ca025571a891333a57012c2cd4419b6581e5. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 116 +++++++++------------ .../CoreModules/Avatar/Friends/FriendsModule.cs | 42 ++++---- .../Avatar/InstantMessage/PresenceModule.cs | 11 +- .../Inventory/Transfer/InventoryTransferModule.cs | 15 ++- .../Scripting/EMailModules/EmailModule.cs | 37 ++++--- .../CoreModules/World/Land/LandManagementModule.cs | 8 +- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 36 +++---- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 36 +++---- 8 files changed, 127 insertions(+), 174 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index fe37a08..0052729 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3122,7 +3122,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP objectData.TextureAnim = textureanim; } - bool doUpdate = false; lock (m_primFullUpdates) { if (m_primFullUpdates.Count == 0) @@ -3131,10 +3130,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primFullUpdates.Add(objectData); if (m_primFullUpdates.Count >= m_primFullUpdatesPerPacket) - doUpdate = true; + ProcessPrimFullUpdates(this, null); } - if (doUpdate) - ProcessPrimFullUpdates(this, null); } void HandleQueueEmpty(ThrottleOutPacketType queue) @@ -3155,40 +3152,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP void ProcessPrimFullUpdates(object sender, ElapsedEventArgs e) { - bool stopTimer = false; lock (m_primFullUpdates) { if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) - stopTimer = true; - } - if (stopTimer) - { - lock (m_primFullUpdateTimer) - m_primFullUpdateTimer.Stop(); - return; - } + { + lock (m_primFullUpdateTimer) + m_primFullUpdateTimer.Stop(); + + return; + } - ObjectUpdatePacket outPacket = - (ObjectUpdatePacket)PacketPool.Instance.GetPacket( - PacketType.ObjectUpdate); + ObjectUpdatePacket outPacket = + (ObjectUpdatePacket)PacketPool.Instance.GetPacket( + PacketType.ObjectUpdate); - outPacket.RegionData.RegionHandle = - Scene.RegionInfo.RegionHandle; - outPacket.RegionData.TimeDilation = - (ushort)(Scene.TimeDilation * ushort.MaxValue); + outPacket.RegionData.RegionHandle = + Scene.RegionInfo.RegionHandle; + outPacket.RegionData.TimeDilation = + (ushort)(Scene.TimeDilation * ushort.MaxValue); - int max = m_primFullUpdates.Count; - if (max > m_primFullUpdatesPerPacket) - max = m_primFullUpdatesPerPacket; + int max = m_primFullUpdates.Count; + if (max > m_primFullUpdatesPerPacket) + max = m_primFullUpdatesPerPacket; - int count = 0; - int size = 0; + int count = 0; + int size = 0; - byte[] zerobuffer = new byte[1024]; - byte[] blockbuffer = new byte[1024]; + byte[] zerobuffer = new byte[1024]; + byte[] blockbuffer = new byte[1024]; - lock (m_primFullUpdates) - { for (count = 0 ; count < max ; count++) { int length = 0; @@ -3212,12 +3204,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) - stopTimer = true; + lock (m_primFullUpdateTimer) + m_primFullUpdateTimer.Stop(); } - - if (stopTimer) - lock (m_primFullUpdateTimer) - m_primFullUpdateTimer.Stop(); } /// @@ -3236,7 +3225,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity, state); - bool doUpdate = false; lock (m_primTerseUpdates) { if (m_primTerseUpdates.Count == 0) @@ -3245,51 +3233,43 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primTerseUpdates.Add(objectData); if (m_primTerseUpdates.Count >= m_primTerseUpdatesPerPacket) - doUpdate = true; + ProcessPrimTerseUpdates(this, null); } - if (doUpdate) - ProcessPrimTerseUpdates(this, null); } void ProcessPrimTerseUpdates(object sender, ElapsedEventArgs e) { - bool stopTimer = false; lock (m_primTerseUpdates) { if (m_primTerseUpdates.Count == 0) - stopTimer = true; - } - if (stopTimer) - { - lock (m_primTerseUpdateTimer) - m_primTerseUpdateTimer.Stop(); + { + lock (m_primTerseUpdateTimer) + m_primTerseUpdateTimer.Stop(); - return; - } + return; + } - ImprovedTerseObjectUpdatePacket outPacket = - (ImprovedTerseObjectUpdatePacket) - PacketPool.Instance.GetPacket( - PacketType.ImprovedTerseObjectUpdate); + ImprovedTerseObjectUpdatePacket outPacket = + (ImprovedTerseObjectUpdatePacket) + PacketPool.Instance.GetPacket( + PacketType.ImprovedTerseObjectUpdate); - outPacket.RegionData.RegionHandle = - Scene.RegionInfo.RegionHandle; - outPacket.RegionData.TimeDilation = - (ushort)(Scene.TimeDilation * ushort.MaxValue); + outPacket.RegionData.RegionHandle = + Scene.RegionInfo.RegionHandle; + outPacket.RegionData.TimeDilation = + (ushort)(Scene.TimeDilation * ushort.MaxValue); - int max = m_primTerseUpdates.Count; - if (max > m_primTerseUpdatesPerPacket) - max = m_primTerseUpdatesPerPacket; + int max = m_primTerseUpdates.Count; + if (max > m_primTerseUpdatesPerPacket) + max = m_primTerseUpdatesPerPacket; - int count = 0; - int size = 0; + int count = 0; + int size = 0; - byte[] zerobuffer = new byte[1024]; - byte[] blockbuffer = new byte[1024]; + byte[] zerobuffer = new byte[1024]; + byte[] blockbuffer = new byte[1024]; - lock (m_primTerseUpdates) - { - for (count = 0; count < max; count++) + for (count = 0 ; count < max ; count++) { int length = 0; m_primTerseUpdates[count].ToBytes(blockbuffer, ref length); @@ -3314,11 +3294,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); if (m_primTerseUpdates.Count == 0) - stopTimer = true; + lock (m_primTerseUpdateTimer) + m_primTerseUpdateTimer.Stop(); } - if (stopTimer) - lock (m_primTerseUpdateTimer) - m_primTerseUpdateTimer.Stop(); } public void FlushPrimUpdates() diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 4abad81..fc7d63a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -442,46 +442,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) { - List scenes = null; - lock (m_scenes) - scenes = new List(m_scenes.Values); - ScenePresence returnAgent = null; - ScenePresence queryagent = null; - foreach (Scene scene in scenes) + lock (m_scenes) { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) + ScenePresence queryagent = null; + foreach (Scene scene in m_scenes.Values) { - if (!queryagent.IsChildAgent) + queryagent = scene.GetScenePresence(AgentID); + if (queryagent != null) { - returnAgent = queryagent; - break; + if (!queryagent.IsChildAgent) + { + returnAgent = queryagent; + break; + } } } } - return returnAgent; } private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) { - 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) + lock (m_scenes) { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) + ScenePresence queryagent = null; + foreach (Scene scene in m_scenes.Values) { - returnAgent = queryagent; - break; + queryagent = scene.GetScenePresence(AgentID); + if (queryagent != null) + { + returnAgent = queryagent; + break; + } } } - return returnAgent; } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index 42dd7ff..ad05bab 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -290,14 +290,13 @@ 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) { - agent = scene.GetScenePresence(agentID); - if (agent != null) break; + foreach (Scene scene in m_Scenes) + { + 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 e6e0483..d9a021f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -111,17 +111,16 @@ 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) { - ScenePresence presence = scene.GetScenePresence(agentId); - if (presence != null) + foreach (Scene scene in m_Scenelist) { - if (!presence.IsChildAgent) - return scene; + ScenePresence presence = scene.GetScenePresence(agentId); + if (presence != null) + { + if (!presence.IsChildAgent) + return scene; + } } } return null; diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index f9f01fe..83f004d 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -198,20 +198,19 @@ 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) { - SceneObjectPart part = s.GetSceneObjectPart(objectID); - if (part != null) + foreach (Scene s in m_Scenes.Values) { - 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; + 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 = string.Empty; @@ -364,7 +363,6 @@ 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) { @@ -377,6 +375,7 @@ 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) @@ -384,15 +383,15 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules removal.Add(uuid); } } - } - foreach (UUID remove in removal) - { - lock (m_LastGetEmailCall) + foreach (UUID remove in removal) + { m_LastGetEmailCall.Remove(remove); - - lock (m_MailQueues) - m_MailQueues.Remove(remove); + lock (m_MailQueues) + { + m_MailQueues.Remove(remove); + } + } } lock (m_MailQueues) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 0fed1bd..d2b5cb1 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -187,16 +187,14 @@ namespace OpenSim.Region.CoreModules.World.Land LandData newData = data.Copy(); newData.LocalID = local_id; - ILandObject land = null; lock (m_landList) { if (m_landList.ContainsKey(local_id)) { m_landList[local_id].LandData = newData; - land = m_landList[local_id]; + m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]); } } - m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, land); } public bool AllowedForcefulBans @@ -506,7 +504,6 @@ namespace OpenSim.Region.CoreModules.World.Land /// Land.localID of the peice of land to remove. public void removeLandObject(int local_id) { - UUID id = UUID.Zero; lock (m_landList) { for (int x = 0; x < 64; x++) @@ -523,10 +520,9 @@ namespace OpenSim.Region.CoreModules.World.Land } } - id = m_landList[local_id].LandData.GlobalID; + m_scene.EventManager.TriggerLandObjectRemoved(m_landList[local_id].LandData.GlobalID); m_landList.Remove(local_id); } - m_scene.EventManager.TriggerLandObjectRemoved(id); } private void performFinalLandJoin(ILandObject master, ILandObject slave) diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index df9473d..5b571c7 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -122,13 +122,12 @@ namespace OpenSim.Region.Framework.Scenes public bool InventoryDeQueueAndDelete() { DeleteToInventoryHolder x = null; - int left = 0; try { lock (m_inventoryDeletes) { - left = m_inventoryDeletes.Count; + int left = m_inventoryDeletes.Count; if (left > 0) { x = m_inventoryDeletes.Dequeue(); @@ -137,26 +136,23 @@ namespace OpenSim.Region.Framework.Scenes m_inventoryDeletes.Enqueue(x); return true; } - } - } - if (left > 0) - { - m_log.DebugFormat( - "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); - - try - { - m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); - if (x.permissionToDelete) - m_scene.DeleteSceneObject(x.objectGroup, false); - } - catch (Exception e) - { - m_log.DebugFormat("Exception background sending object: " + e); + m_log.DebugFormat( + "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); + + try + { + m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); + if (x.permissionToDelete) + m_scene.DeleteSceneObject(x.objectGroup, false); + } + catch (Exception e) + { + m_log.DebugFormat("Exception background sending object: " + e); + } + + return true; } - - return true; } } catch (Exception e) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 20b3b5c..54ac792 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -297,44 +297,34 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.AttachToScene(m_parentScene); - List parts = null; - bool found = false; lock (sceneObject) { if (!Entities.ContainsKey(sceneObject.UUID)) { - found = true; Entities.Add(sceneObject); m_numPrim += sceneObject.Children.Count; if (attachToBackup) sceneObject.AttachToBackup(); - parts = new List(sceneObject.Children.Values); - - } - } - - if (found) - { - lock (m_dictionary_lock) - { - SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; - SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; - foreach (SceneObjectPart part in parts) + if (OnObjectCreate != null) + OnObjectCreate(sceneObject); + + lock (m_dictionary_lock) { - SceneObjectGroupsByFullID[part.UUID] = sceneObject; - SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; + SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; + SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; + foreach (SceneObjectPart part in sceneObject.Children.Values) + { + SceneObjectGroupsByFullID[part.UUID] = sceneObject; + SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; + } } - } - if (OnObjectCreate != null) - OnObjectCreate(sceneObject); - - return true; + return true; + } } - return false; } -- cgit v1.1 From b5b53dd3ebb331c5d235df161fe9cefc405c3660 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 19:55:35 -0700 Subject: * One more debug message on FetchInventoryDescendants * More streams close on finally --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a4460e4..1917228 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1168,6 +1168,7 @@ namespace OpenSim.Region.Framework.Scenes private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) { + m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems); } -- cgit v1.1