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. --- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 36 ++++++++++++---------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 36 ++++++++++++++-------- 2 files changed, 43 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 5b571c7..df9473d 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -122,12 +122,13 @@ namespace OpenSim.Region.Framework.Scenes public bool InventoryDeQueueAndDelete() { DeleteToInventoryHolder x = null; + int left = 0; try { lock (m_inventoryDeletes) { - int left = m_inventoryDeletes.Count; + left = m_inventoryDeletes.Count; if (left > 0) { x = m_inventoryDeletes.Dequeue(); @@ -136,23 +137,26 @@ namespace OpenSim.Region.Framework.Scenes m_inventoryDeletes.Enqueue(x); return true; } + } + } - 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; + 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); } + + return true; } } catch (Exception e) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 54ac792..20b3b5c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -297,34 +297,44 @@ 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(); - if (OnObjectCreate != null) - OnObjectCreate(sceneObject); - - lock (m_dictionary_lock) + 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) { - SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; - SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; - foreach (SceneObjectPart part in sceneObject.Children.Values) - { - SceneObjectGroupsByFullID[part.UUID] = sceneObject; - SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; - } + SceneObjectGroupsByFullID[part.UUID] = sceneObject; + SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; } - - return true; } + + if (OnObjectCreate != null) + OnObjectCreate(sceneObject); + + return true; } + return false; } -- cgit v1.1