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

httptests
UbitUmarov 2017-05-04 11:37:13 +01:00
parent d62aed7f46
commit 3a8dd24fd1
9 changed files with 48 additions and 84 deletions

View File

@ -1182,7 +1182,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
rootPart.TrimPermissions();
so.AggregateDeepPerms();
so.InvalidateDeepEffectivePerms();
if (isAttachment)
so.FromItemID = item.ID;

View File

@ -238,6 +238,16 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public bool LegacySitOffsets = true;
/// <summary>
/// set false to not propagare group rights outwards as legacy did
/// </summary>
public bool PropagateGroupShareOutwards = true;
/// <summary>
/// set false to not propagare Everyone rights outwards as legacy did
/// </summary>
public bool PropagateAnyOneOutwards = true;
/// <summary>
/// Can avatars cross from and to this region?
/// </summary>
@ -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;

View File

@ -343,7 +343,7 @@ namespace OpenSim.Region.Framework.Scenes
sceneObject.ForceInventoryPersistence();
sceneObject.HasGroupChanged = true;
}
sceneObject.AggregateDeepPerms();
sceneObject.InvalidateDeepEffectivePerms();
return ret;
}

View File

@ -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)

View File

@ -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();

View File

@ -979,7 +979,7 @@ namespace OpenSim.Region.Framework.Scenes
}
// old code end
rootPart.TrimPermissions();
group.AggregateDeepPerms();
group.InvalidateDeepEffectivePerms();
}
return true;

View File

@ -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)

View File

@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
//obj.RegenerateFullIDs();
scene.AddNewSceneObject(obj, true);
obj.AggregateDeepPerms();
obj.InvalidateDeepEffectivePerms();
}
}
else

View File

@ -626,6 +626,7 @@ namespace OpenSim.Tests.Common
//part.ObjectFlags |= (uint)PrimFlags.Phantom;
scene.AddNewSceneObject(so, true);
so.InvalidateDeepEffectivePerms();
return so;
}
@ -652,6 +653,7 @@ namespace OpenSim.Tests.Common
SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail);
scene.AddNewSceneObject(so, false);
so.InvalidateDeepEffectivePerms();
return so;
}