From 46c6c35d4868e4ff538bdc2c65a7fade936c0ce1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Aug 2010 22:46:49 +0100 Subject: refactor: Push item retrieval and fixing part of Scene.RezObject() down into SceneObjectPartInventory --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 59 +++------------------- 1 file changed, 6 insertions(+), 53 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 01be491..9fef8f4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1969,60 +1969,13 @@ namespace OpenSim.Region.Framework.Scenes if (null == item) return null; - UUID ownerID = item.OwnerID; - AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); - - if (null == rezAsset) - return null; - - string xmlData = Utils.BytesToString(rezAsset.Data); - SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); - - if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos)) + SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item); + + if (null == group) return null; - - group.ResetIDs(); - - SceneObjectPart rootPart = group.GetChildPart(group.UUID); - - // Since renaming the item in the inventory does not affect the name stored - // in the serialization, transfer the correct name from the inventory to the - // object itself before we rez. - rootPart.Name = item.Name; - rootPart.Description = item.Description; - - List partList = new List(group.Children.Values); - - group.SetGroup(sourcePart.GroupID, null); - - if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) - { - if (Permissions.PropagatePermissions()) - { - foreach (SceneObjectPart part in partList) - { - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; - } - - group.ApplyNextOwnerPermissions(); - } - } - - foreach (SceneObjectPart part in partList) - { - if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) - { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.OwnerID; - part.Inventory.ChangeInventoryOwner(item.OwnerID); - } - - part.EveryoneMask = item.EveryonePermissions; - part.NextOwnerMask = item.NextPermissions; - } - rootPart.TrimPermissions(); + if (!Permissions.CanRezObject(group.Children.Count, item.OwnerID, pos)) + return null; if (!Permissions.BypassPermissions()) { @@ -2038,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes group.ScheduleGroupForFullUpdate(); - return rootPart.ParentGroup; + return group; } public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) -- cgit v1.1 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