From 8031f8ec09df4f654c86a9c7bc498664f7b9d9dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Aug 2010 00:08:53 +0100 Subject: Improve consistency of locking for SOG.m_parts in order to avoid race conditions in linking and unlinking --- .../ContentManagementSystem/MetaEntity.cs | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs') diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs index 841ee00..796f437 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs @@ -150,15 +150,19 @@ namespace OpenSim.Region.OptionalModules.ContentManagement { //make new uuids Dictionary parts = new Dictionary(); - foreach (SceneObjectPart part in m_Entity.Children.Values) + + lock (m_Entity.Children) { - part.ResetIDs(part.LinkNum); - parts.Add(part.UUID, part); + foreach (SceneObjectPart part in m_Entity.Children.Values) + { + part.ResetIDs(part.LinkNum); + parts.Add(part.UUID, part); + } + + //finalize + m_Entity.RootPart.PhysActor = null; + m_Entity.Children = parts; } - - //finalize - m_Entity.RootPart.PhysActor = null; - m_Entity.Children = parts; } #endregion Protected Methods @@ -173,8 +177,11 @@ namespace OpenSim.Region.OptionalModules.ContentManagement //This deletes the group without removing from any databases. //This is important because we are not IN any database. //m_Entity.FakeDeleteGroup(); - foreach (SceneObjectPart part in m_Entity.Children.Values) - client.SendKillObject(m_Entity.RegionHandle, part.LocalId); + lock (m_Entity.Children) + { + foreach (SceneObjectPart part in m_Entity.Children.Values) + client.SendKillObject(m_Entity.RegionHandle, part.LocalId); + } } /// @@ -182,12 +189,15 @@ namespace OpenSim.Region.OptionalModules.ContentManagement /// public virtual void HideFromAll() { - foreach (SceneObjectPart part in m_Entity.Children.Values) + lock (m_Entity.Children) { - m_Entity.Scene.ForEachClient( - delegate(IClientAPI controller) - { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); } - ); + foreach (SceneObjectPart part in m_Entity.Children.Values) + { + m_Entity.Scene.ForEachClient( + delegate(IClientAPI controller) + { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); } + ); + } } } -- cgit v1.1