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 --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9fef8f4..379128a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1974,7 +1974,7 @@ namespace OpenSim.Region.Framework.Scenes if (null == group) return null; - if (!Permissions.CanRezObject(group.Children.Count, item.OwnerID, pos)) + if (!Permissions.CanRezObject(group.PrimCount, item.OwnerID, pos)) return null; if (!Permissions.BypassPermissions()) @@ -2051,8 +2051,11 @@ namespace OpenSim.Region.Framework.Scenes sog.SetGroup(groupID, remoteClient); sog.ScheduleGroupForFullUpdate(); - foreach (SceneObjectPart child in sog.Children.Values) - child.Inventory.ChangeInventoryOwner(ownerID); + lock (sog.Children) + { + foreach (SceneObjectPart child in sog.Children.Values) + child.Inventory.ChangeInventoryOwner(ownerID); + } } else { @@ -2062,16 +2065,18 @@ namespace OpenSim.Region.Framework.Scenes if (sog.GroupID != groupID) continue; - foreach (SceneObjectPart child in sog.Children.Values) + lock (sog.Children) { - child.LastOwnerID = child.OwnerID; - child.Inventory.ChangeInventoryOwner(groupID); + foreach (SceneObjectPart child in sog.Children.Values) + { + child.LastOwnerID = child.OwnerID; + child.Inventory.ChangeInventoryOwner(groupID); + } } sog.SetOwnerId(groupID); sog.ApplyNextOwnerPermissions(); - } - + } } foreach (uint localID in localIDs) -- cgit v1.1