chance new effective permissions code to ease aggregation on demand( ie on changes). But still doing full aggregation on checks, so still heavy
parent
d78f04b326
commit
733072b6a3
|
@ -80,15 +80,17 @@ namespace OpenSim.Framework
|
|||
FoldedMask = 0x0f,
|
||||
|
||||
//
|
||||
Transfer = 1 << 13,
|
||||
Modify = 1 << 14,
|
||||
Copy = 1 << 15,
|
||||
Export = 1 << 16,
|
||||
Move = 1 << 19,
|
||||
Damage = 1 << 20,
|
||||
Transfer = 1 << 13, // 0x02000
|
||||
Modify = 1 << 14, // 0x04000
|
||||
Copy = 1 << 15, // 0x08000
|
||||
Export = 1 << 16, // 0x10000
|
||||
Move = 1 << 19, // 0x80000
|
||||
Damage = 1 << 20, // 0x100000 does not seem to be in use
|
||||
// All does not contain Export, which is special and must be
|
||||
// explicitly given
|
||||
All = (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19)
|
||||
All = 0x8e000,
|
||||
AllAndExport = 0x9e000,
|
||||
AllEffective = 0x9e000
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -278,10 +278,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <param name="datastore"></param>
|
||||
void ProcessInventoryBackup(ISimulationDataService datastore);
|
||||
|
||||
void AggregateEveryOnePerms(ref uint current);
|
||||
void AggregateGroupOrEveryonePerms(ref uint current);
|
||||
void AggregateGroupPerms(ref uint current);
|
||||
void AggregateOwnerPerms(ref uint current);
|
||||
void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone);
|
||||
|
||||
uint MaskEffectivePermissions();
|
||||
|
||||
|
|
|
@ -259,41 +259,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
|
||||
// bc this is on heavy duty code paths
|
||||
// but for now we need to test the concept
|
||||
AggregateEveryOnePerms();
|
||||
AggregateDeepPerms();
|
||||
return m_EffectiveEveryOnePerms;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateEveryOnePerms()
|
||||
{
|
||||
lock(PermissionsLock)
|
||||
{
|
||||
// get object everyone permissions
|
||||
uint baseperms = RootPart.EveryoneMask & (uint)PermissionMask.All;
|
||||
|
||||
if(baseperms == 0)
|
||||
{
|
||||
m_EffectiveEveryOnePerms = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint current = baseperms;
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart part = parts[i];
|
||||
part.Inventory.AggregateEveryOnePerms(ref current);
|
||||
if( current == 0)
|
||||
break;
|
||||
}
|
||||
// recover move
|
||||
baseperms &= (uint)PermissionMask.Move;
|
||||
current |= baseperms;
|
||||
current &= (uint)PermissionMask.All;
|
||||
m_EffectiveEveryOnePerms = current;
|
||||
}
|
||||
}
|
||||
|
||||
private uint m_EffectiveGroupPerms;
|
||||
public uint EffectiveGroupPerms
|
||||
{
|
||||
|
@ -302,42 +272,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
|
||||
// bc this is on heavy duty code paths
|
||||
// but for now we need to test the concept
|
||||
AggregateGroupPerms();
|
||||
AggregateDeepPerms();
|
||||
return m_EffectiveGroupPerms;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateGroupPerms()
|
||||
{
|
||||
lock(PermissionsLock)
|
||||
{
|
||||
// get object everyone permissions
|
||||
uint baseperms = RootPart.GroupMask & (uint)PermissionMask.All;
|
||||
|
||||
if(baseperms == 0)
|
||||
{
|
||||
m_EffectiveGroupPerms = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint current = baseperms;
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart part = parts[i];
|
||||
part.Inventory.AggregateGroupPerms(ref current);
|
||||
if( current == 0)
|
||||
break;
|
||||
}
|
||||
// recover modify and move
|
||||
baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify );
|
||||
current |= baseperms;
|
||||
current &= (uint)PermissionMask.All;
|
||||
m_EffectiveGroupPerms = current;
|
||||
}
|
||||
}
|
||||
|
||||
private uint m_EffectiveGroupOrEveryOnePerms;
|
||||
public uint EffectiveGroupOrEveryOnePerms
|
||||
{
|
||||
get
|
||||
|
@ -345,38 +284,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
|
||||
// bc this is on heavy duty code paths
|
||||
// but for now we need to test the concept
|
||||
AggregateGroupOrEveryOnePerms();
|
||||
return m_EffectiveGroupOrEveryOnePerms;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateGroupOrEveryOnePerms()
|
||||
{
|
||||
lock(PermissionsLock)
|
||||
{
|
||||
// get object everyone permissions
|
||||
uint baseperms = (RootPart.EveryoneMask | RootPart.GroupMask) & (uint)PermissionMask.All;
|
||||
|
||||
if(baseperms == 0)
|
||||
{
|
||||
m_EffectiveGroupOrEveryOnePerms = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint current = baseperms;
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart part = parts[i];
|
||||
part.Inventory.AggregateGroupOrEveryonePerms(ref current);
|
||||
if( current == 0)
|
||||
break;
|
||||
}
|
||||
// recover modify and move
|
||||
baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify );
|
||||
current |= baseperms;
|
||||
current &= (uint)PermissionMask.All;
|
||||
m_EffectiveGroupOrEveryOnePerms = current;
|
||||
AggregateDeepPerms();
|
||||
return m_EffectiveEveryOnePerms | m_EffectiveGroupPerms;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,40 +297,111 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
|
||||
// bc this is on heavy duty code paths
|
||||
// but for now we need to test the concept
|
||||
AggregateOwnerPerms();
|
||||
AggregateDeepPerms();
|
||||
return m_EffectiveOwnerPerms;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateOwnerPerms()
|
||||
// aggregates perms scanning parts and their contents
|
||||
public void AggregateDeepPerms()
|
||||
{
|
||||
lock(PermissionsLock)
|
||||
{
|
||||
// get object everyone permissions
|
||||
uint baseperms = RootPart.OwnerMask & (uint)PermissionMask.All;
|
||||
// aux
|
||||
const uint allmask = (uint)PermissionMask.AllEffective;
|
||||
const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
|
||||
const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
|
||||
|
||||
uint baseOwnerPerms = RootPart.OwnerMask;
|
||||
uint owner = baseOwnerPerms;
|
||||
uint baseGroupPerms = RootPart.GroupMask;
|
||||
uint group = baseGroupPerms;
|
||||
uint baseEveryonePerms = RootPart.EveryoneMask;
|
||||
uint everyone = baseEveryonePerms;
|
||||
|
||||
if(baseperms == 0)
|
||||
{
|
||||
m_EffectiveOwnerPerms = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint current = baseperms;
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart part = parts[i];
|
||||
part.Inventory.AggregateOwnerPerms(ref current);
|
||||
if( current == 0)
|
||||
break;
|
||||
part.AggregateInnerPerms();
|
||||
owner &= part.AggregatedInnerOwnerPerms;
|
||||
group &= part.AggregatedInnerGroupPerms;
|
||||
everyone &= part.AggregatedInnerEveryonePerms;
|
||||
}
|
||||
// recover modify and move
|
||||
baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify );
|
||||
current |= baseperms;
|
||||
current &= (uint)PermissionMask.All;
|
||||
if((current & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0)
|
||||
current |= (uint)PermissionMask.Transfer;
|
||||
m_EffectiveOwnerPerms = current;
|
||||
baseOwnerPerms &= movemodmask;
|
||||
owner |= baseOwnerPerms;
|
||||
if((owner & copytransfermast) == 0)
|
||||
owner |= (uint)PermissionMask.Transfer;
|
||||
owner &= allmask;
|
||||
m_EffectiveOwnerPerms = owner;
|
||||
|
||||
// recover modify and move
|
||||
baseGroupPerms &= movemodmask;
|
||||
group |= baseGroupPerms;
|
||||
if((group & copytransfermast) == 0)
|
||||
group |= (uint)PermissionMask.Transfer;
|
||||
group &= allmask;
|
||||
m_EffectiveGroupPerms = group;
|
||||
|
||||
// recover move
|
||||
baseEveryonePerms &= (uint)PermissionMask.Move;
|
||||
everyone |= baseEveryonePerms;
|
||||
if((everyone & copytransfermast) == 0) // not much sense but as sl
|
||||
everyone |= (uint)PermissionMask.Transfer;
|
||||
everyone &= allmask;
|
||||
m_EffectiveEveryOnePerms = everyone;
|
||||
}
|
||||
}
|
||||
|
||||
// aggregates perms scanning parts, assuming their contents was already aggregated
|
||||
public void AggregatePerms()
|
||||
{
|
||||
lock(PermissionsLock)
|
||||
{
|
||||
// aux
|
||||
const uint allmask = (uint)PermissionMask.AllEffective;
|
||||
const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
|
||||
const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
|
||||
|
||||
uint baseOwnerPerms = RootPart.OwnerMask;
|
||||
uint owner = baseOwnerPerms;
|
||||
uint baseGroupPerms = RootPart.GroupMask;
|
||||
uint group = baseGroupPerms;
|
||||
uint baseEveryonePerms = RootPart.EveryoneMask;
|
||||
uint everyone = baseEveryonePerms;
|
||||
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart part = parts[i];
|
||||
owner &= part.AggregatedInnerOwnerPerms;
|
||||
group &= part.AggregatedInnerGroupPerms;
|
||||
everyone &= part.AggregatedInnerEveryonePerms;
|
||||
}
|
||||
// recover modify and move
|
||||
baseOwnerPerms &= movemodmask;
|
||||
owner |= baseOwnerPerms;
|
||||
if((owner & copytransfermast) == 0)
|
||||
owner |= (uint)PermissionMask.Transfer;
|
||||
owner &= allmask;
|
||||
m_EffectiveOwnerPerms = owner;
|
||||
|
||||
// recover modify and move
|
||||
baseGroupPerms &= movemodmask;
|
||||
group |= baseGroupPerms;
|
||||
if((group & copytransfermast) == 0)
|
||||
group |= (uint)PermissionMask.Transfer;
|
||||
group &= allmask;
|
||||
m_EffectiveGroupPerms = group;
|
||||
|
||||
// recover move
|
||||
baseEveryonePerms &= (uint)PermissionMask.Move;
|
||||
everyone |= baseEveryonePerms;
|
||||
if((everyone & copytransfermast) == 0) // not much sense but as sl
|
||||
everyone |= (uint)PermissionMask.Transfer;
|
||||
everyone &= allmask;
|
||||
m_EffectiveEveryOnePerms = everyone;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2537,6 +2537,33 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return (uint)Flags | (uint)LocalFlags;
|
||||
}
|
||||
|
||||
// some of this lines need be moved to other place later
|
||||
|
||||
// effective permitions considering only this part inventory contents perms
|
||||
public uint AggregatedInnerOwnerPerms {get; private set; }
|
||||
public uint AggregatedInnerGroupPerms {get; private set; }
|
||||
public uint AggregatedInnerEveryonePerms {get; private set; }
|
||||
private object InnerPermsLock = new object();
|
||||
|
||||
public void AggregateInnerPerms()
|
||||
{
|
||||
const uint mask = (uint)PermissionMask.AllEffective;
|
||||
|
||||
uint owner = mask;
|
||||
uint group = mask;
|
||||
uint everyone = mask;
|
||||
|
||||
lock(InnerPermsLock) // do we really need this?
|
||||
{
|
||||
if(Inventory != null)
|
||||
Inventory.AggregateInnerPerms(ref owner, ref group, ref everyone);
|
||||
|
||||
AggregatedInnerOwnerPerms = owner & mask;
|
||||
AggregatedInnerGroupPerms = group & mask;
|
||||
AggregatedInnerEveryonePerms = everyone & mask;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetGeometricCenter()
|
||||
{
|
||||
// this is not real geometric center but a average of positions relative to root prim acording to
|
||||
|
|
|
@ -1317,48 +1317,16 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
// reduce to minimal set
|
||||
public void AggregateEveryOnePerms(ref uint current)
|
||||
public void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
current &= item.EveryonePermissions;
|
||||
if(current == 0)
|
||||
break;
|
||||
owner &= item.CurrentPermissions;
|
||||
group &= item.GroupPermissions;
|
||||
everyone &= item.EveryonePermissions;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateGroupPerms(ref uint current)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
current &= item.GroupPermissions;
|
||||
if(current == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateGroupOrEveryonePerms(ref uint current)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
current &= (item.GroupPermissions | item.EveryonePermissions);
|
||||
if(current == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void AggregateOwnerPerms(ref uint current)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
current &= item.CurrentPermissions;
|
||||
if(current == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public uint MaskEffectivePermissions()
|
||||
{
|
||||
uint mask=0x7fffffff;
|
||||
|
|
Loading…
Reference in New Issue