From 3a8dd24fd1c1aead0a81a4a9d63b59bbf9f10855 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 May 2017 11:37:13 +0100 Subject: move deep effective permissions aggregation to first time use and not on changes. There flag it is need with InvalidateDeepEffectivePerms(). Add config options PropagateGroupShareOutwards and PropagateAnyOneOutwards --- OpenSim/Region/Framework/Scenes/Scene.cs | 18 +++- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 98 +++++----------------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 2 +- .../Scenes/Serialization/SceneObjectSerializer.cs | 4 +- .../Scenes/Serialization/SceneXmlLoader.cs | 2 +- 7 files changed, 45 insertions(+), 83 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 715ae5c..205a321 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -239,6 +239,16 @@ namespace OpenSim.Region.Framework.Scenes public bool LegacySitOffsets = true; /// + /// set false to not propagare group rights outwards as legacy did + /// + public bool PropagateGroupShareOutwards = true; + + /// + /// set false to not propagare Everyone rights outwards as legacy did + /// + public bool PropagateAnyOneOutwards = true; + + /// /// Can avatars cross from and to this region? /// public bool AllowAvatarCrossing { get; set; } @@ -978,7 +988,10 @@ namespace OpenSim.Region.Framework.Scenes m_maxDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); m_maxRegionViewDistance = startupConfig.GetFloat("MaxRegionsViewDistance", m_maxRegionViewDistance); + // old versions compatibility LegacySitOffsets = startupConfig.GetBoolean("LegacySitOffsets", LegacySitOffsets); + PropagateGroupShareOutwards = startupConfig.GetBoolean("PropagateGroupShareOutwards", PropagateGroupShareOutwards); + PropagateAnyOneOutwards = startupConfig.GetBoolean("PropagateAnyOneOutwards", PropagateAnyOneOutwards); if (m_defaultDrawDistance > m_maxDrawDistance) m_defaultDrawDistance = m_maxDrawDistance; @@ -2390,8 +2403,9 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnSceneObjectLoaded(group); SceneObjectPart rootPart = group.GetPart(group.UUID); rootPart.Flags &= ~PrimFlags.Scripted; - group.AggregateDeepPerms(); + rootPart.TrimPermissions(); + group.InvalidateDeepEffectivePerms(); // Don't do this here - it will get done later on when sculpt data is loaded. // group.CheckSculptAndLoad(); @@ -2662,7 +2676,7 @@ namespace OpenSim.Region.Framework.Scenes if (UserManagementModule != null) sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); - sceneObject.AggregateDeepPerms(); + sceneObject.InvalidateDeepEffectivePerms();; sceneObject.ScheduleGroupForFullUpdate(); return sceneObject; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a005068..91d2879 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -343,7 +343,7 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.ForceInventoryPersistence(); sceneObject.HasGroupChanged = true; } - sceneObject.AggregateDeepPerms(); + sceneObject.InvalidateDeepEffectivePerms(); return ret; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 36844a9..95a5887 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -254,13 +254,26 @@ namespace OpenSim.Region.Framework.Scenes // new test code, to place in better place later private object m_PermissionsLock = new object(); private bool m_EffectivePermsInvalid = true; + private bool m_DeepEffectivePermsInvalid = true; + // should called when parts chanced by their contents did not, so we know their cacche is valid + // in case of doubt call InvalidateDeepEffectivePerms(), it only costs a bit more cpu time public void InvalidateEffectivePerms() { lock(m_PermissionsLock) m_EffectivePermsInvalid = true; } + // should called when parts chanced and their contents where accounted for + public void InvalidateDeepEffectivePerms() + { + lock(m_PermissionsLock) + { + m_DeepEffectivePermsInvalid = true; + m_EffectivePermsInvalid = true; + } + } + private uint m_EffectiveEveryOnePerms; public uint EffectiveEveryOnePerms { @@ -317,79 +330,6 @@ namespace OpenSim.Region.Framework.Scenes } } - // aggregates perms scanning parts and their contents - // AggregatePerms does same using cached parts content perms - public void AggregateDeepPerms() - { - lock(m_PermissionsLock) - { - // aux - const uint allmask = (uint)PermissionMask.AllEffective; - const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); - const uint copytransfermask = (uint)(PermissionMask.Copy | PermissionMask.Transfer); - - uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move; - bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0; - - uint rootOwnerPerms = RootPart.OwnerMask; - uint owner = rootOwnerPerms; - uint rootGroupPerms = RootPart.GroupMask; - uint group = rootGroupPerms; - uint rootEveryonePerms = RootPart.EveryoneMask; - uint everyone = rootEveryonePerms; - - // date is time of writing april 30th 2017 - bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - part.AggregateInnerPerms(); - owner &= part.AggregatedInnerOwnerPerms; - group &= part.AggregatedInnerGroupPerms; - if(newObject) - everyone &= part.AggregatedInnerEveryonePerms; - } - // recover modify and move - rootOwnerPerms &= movemodmask; - owner |= rootOwnerPerms; - if((owner & copytransfermask) == 0) - owner |= (uint)PermissionMask.Transfer; - - owner &= basePerms; - m_EffectiveOwnerPerms = owner; - uint ownertransfermask = owner & (uint)PermissionMask.Transfer; - - // recover modify and move - rootGroupPerms &= movemodmask; - group |= rootGroupPerms; - if(noBaseTransfer) - group &=~(uint)PermissionMask.Copy; - else - group |= ownertransfermask; - - uint groupOrEveryone = group; - m_EffectiveGroupPerms = group & owner; - - // recover move - rootEveryonePerms &= (uint)PermissionMask.Move; - everyone |= rootEveryonePerms; - everyone &= ~(uint)PermissionMask.Modify; - if(noBaseTransfer) - everyone &=~(uint)PermissionMask.Copy; - else - everyone |= ownertransfermask; - - groupOrEveryone |= everyone; - - m_EffectiveEveryOnePerms = everyone & owner; - m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner; - m_EffectivePermsInvalid = false; - } - } - - // aggregates perms scanning parts, assuming their contents was already aggregated and cached - // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop public void AggregatePerms() { lock(m_PermissionsLock) @@ -410,15 +350,22 @@ namespace OpenSim.Region.Framework.Scenes uint everyone = rootEveryonePerms; bool needUpdate = false; + bool propGroupOut = Scene.PropagateGroupShareOutwards; // date is time of writing april 30th 2017 - bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); + bool propAnyOut = Scene.PropagateAnyOneOutwards & (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; + + if(m_DeepEffectivePermsInvalid) + part.AggregateInnerPerms(); + owner &= part.AggregatedInnerOwnerPerms; group &= part.AggregatedInnerGroupPerms; - if(newObject) + if(propGroupOut) + group &= part.AggregatedInnerGroupPerms; + if(propAnyOut) everyone &= part.AggregatedInnerEveryonePerms; } // recover modify and move @@ -477,6 +424,7 @@ namespace OpenSim.Region.Framework.Scenes m_EffectiveGroupOrEveryOnePerms = tmpPerms; } + m_DeepEffectivePermsInvalid = false; m_EffectivePermsInvalid = false; if(needUpdate) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e73795e..512656b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2677,7 +2677,7 @@ namespace OpenSim.Region.Framework.Scenes if (dupe.m_rootPart.PhysActor != null) dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building - dupe.AggregateDeepPerms(); + dupe.InvalidateDeepEffectivePerms(); dupe.HasGroupChanged = true; dupe.AttachToBackup(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4df1f27..21bc19e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -979,7 +979,7 @@ namespace OpenSim.Region.Framework.Scenes } // old code end rootPart.TrimPermissions(); - group.AggregateDeepPerms(); + group.InvalidateDeepEffectivePerms(); } return true; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 87d1ace..892403b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(reader); - sceneObject.AggregateDeepPerms(); + sceneObject.InvalidateDeepEffectivePerms(); return sceneObject; } @@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(doc); - sceneObject.AggregatePerms(); +// sceneObject.AggregatePerms(); return sceneObject; } catch (Exception e) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index 0f022dd..34fdb6d 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //obj.RegenerateFullIDs(); scene.AddNewSceneObject(obj, true); - obj.AggregateDeepPerms(); + obj.InvalidateDeepEffectivePerms(); } } else -- cgit v1.1