diff options
author | UbitUmarov | 2017-01-16 19:01:41 +0000 |
---|---|---|
committer | UbitUmarov | 2017-01-16 19:01:41 +0000 |
commit | 733072b6a371f52d5c13f61d4b2a145a370370f5 (patch) | |
tree | 4944059a40baec7bbb70c341a57ea1f82345b830 /OpenSim | |
parent | Merge branch 'melanie' (diff) | |
download | opensim-SC_OLD-733072b6a371f52d5c13f61d4b2a145a370370f5.zip opensim-SC_OLD-733072b6a371f52d5c13f61d4b2a145a370370f5.tar.gz opensim-SC_OLD-733072b6a371f52d5c13f61d4b2a145a370370f5.tar.bz2 opensim-SC_OLD-733072b6a371f52d5c13f61d4b2a145a370370f5.tar.xz |
chance new effective permissions code to ease aggregation on demand( ie on changes). But still doing full aggregation on checks, so still heavy
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 198 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 27 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 40 |
5 files changed, 130 insertions, 156 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0037f4f..9f5868b 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -80,15 +80,17 @@ namespace OpenSim.Framework | |||
80 | FoldedMask = 0x0f, | 80 | FoldedMask = 0x0f, |
81 | 81 | ||
82 | // | 82 | // |
83 | Transfer = 1 << 13, | 83 | Transfer = 1 << 13, // 0x02000 |
84 | Modify = 1 << 14, | 84 | Modify = 1 << 14, // 0x04000 |
85 | Copy = 1 << 15, | 85 | Copy = 1 << 15, // 0x08000 |
86 | Export = 1 << 16, | 86 | Export = 1 << 16, // 0x10000 |
87 | Move = 1 << 19, | 87 | Move = 1 << 19, // 0x80000 |
88 | Damage = 1 << 20, | 88 | Damage = 1 << 20, // 0x100000 does not seem to be in use |
89 | // All does not contain Export, which is special and must be | 89 | // All does not contain Export, which is special and must be |
90 | // explicitly given | 90 | // explicitly given |
91 | All = (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19) | 91 | All = 0x8e000, |
92 | AllAndExport = 0x9e000, | ||
93 | AllEffective = 0x9e000 | ||
92 | } | 94 | } |
93 | 95 | ||
94 | /// <summary> | 96 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2af6ff0..e7c2428 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -278,10 +278,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
278 | /// <param name="datastore"></param> | 278 | /// <param name="datastore"></param> |
279 | void ProcessInventoryBackup(ISimulationDataService datastore); | 279 | void ProcessInventoryBackup(ISimulationDataService datastore); |
280 | 280 | ||
281 | void AggregateEveryOnePerms(ref uint current); | 281 | void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone); |
282 | void AggregateGroupOrEveryonePerms(ref uint current); | ||
283 | void AggregateGroupPerms(ref uint current); | ||
284 | void AggregateOwnerPerms(ref uint current); | ||
285 | 282 | ||
286 | uint MaskEffectivePermissions(); | 283 | uint MaskEffectivePermissions(); |
287 | 284 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index f44604b..7b9ea8b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -259,41 +259,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | 259 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) |
260 | // bc this is on heavy duty code paths | 260 | // bc this is on heavy duty code paths |
261 | // but for now we need to test the concept | 261 | // but for now we need to test the concept |
262 | AggregateEveryOnePerms(); | 262 | AggregateDeepPerms(); |
263 | return m_EffectiveEveryOnePerms; | 263 | return m_EffectiveEveryOnePerms; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | public void AggregateEveryOnePerms() | ||
268 | { | ||
269 | lock(PermissionsLock) | ||
270 | { | ||
271 | // get object everyone permissions | ||
272 | uint baseperms = RootPart.EveryoneMask & (uint)PermissionMask.All; | ||
273 | |||
274 | if(baseperms == 0) | ||
275 | { | ||
276 | m_EffectiveEveryOnePerms = 0; | ||
277 | return; | ||
278 | } | ||
279 | |||
280 | uint current = baseperms; | ||
281 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
282 | for (int i = 0; i < parts.Length; i++) | ||
283 | { | ||
284 | SceneObjectPart part = parts[i]; | ||
285 | part.Inventory.AggregateEveryOnePerms(ref current); | ||
286 | if( current == 0) | ||
287 | break; | ||
288 | } | ||
289 | // recover move | ||
290 | baseperms &= (uint)PermissionMask.Move; | ||
291 | current |= baseperms; | ||
292 | current &= (uint)PermissionMask.All; | ||
293 | m_EffectiveEveryOnePerms = current; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | private uint m_EffectiveGroupPerms; | 267 | private uint m_EffectiveGroupPerms; |
298 | public uint EffectiveGroupPerms | 268 | public uint EffectiveGroupPerms |
299 | { | 269 | { |
@@ -302,126 +272,136 @@ namespace OpenSim.Region.Framework.Scenes | |||
302 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | 272 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) |
303 | // bc this is on heavy duty code paths | 273 | // bc this is on heavy duty code paths |
304 | // but for now we need to test the concept | 274 | // but for now we need to test the concept |
305 | AggregateGroupPerms(); | 275 | AggregateDeepPerms(); |
306 | return m_EffectiveGroupPerms; | 276 | return m_EffectiveGroupPerms; |
307 | } | 277 | } |
308 | } | 278 | } |
309 | 279 | ||
310 | public void AggregateGroupPerms() | 280 | public uint EffectiveGroupOrEveryOnePerms |
311 | { | 281 | { |
312 | lock(PermissionsLock) | 282 | get |
313 | { | 283 | { |
314 | // get object everyone permissions | 284 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) |
315 | uint baseperms = RootPart.GroupMask & (uint)PermissionMask.All; | 285 | // bc this is on heavy duty code paths |
316 | 286 | // but for now we need to test the concept | |
317 | if(baseperms == 0) | 287 | AggregateDeepPerms(); |
318 | { | 288 | return m_EffectiveEveryOnePerms | m_EffectiveGroupPerms; |
319 | m_EffectiveGroupPerms = 0; | ||
320 | return; | ||
321 | } | ||
322 | |||
323 | uint current = baseperms; | ||
324 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
325 | for (int i = 0; i < parts.Length; i++) | ||
326 | { | ||
327 | SceneObjectPart part = parts[i]; | ||
328 | part.Inventory.AggregateGroupPerms(ref current); | ||
329 | if( current == 0) | ||
330 | break; | ||
331 | } | ||
332 | // recover modify and move | ||
333 | baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); | ||
334 | current |= baseperms; | ||
335 | current &= (uint)PermissionMask.All; | ||
336 | m_EffectiveGroupPerms = current; | ||
337 | } | 289 | } |
338 | } | 290 | } |
339 | 291 | ||
340 | private uint m_EffectiveGroupOrEveryOnePerms; | 292 | private uint m_EffectiveOwnerPerms; |
341 | public uint EffectiveGroupOrEveryOnePerms | 293 | public uint EffectiveOwnerPerms |
342 | { | 294 | { |
343 | get | 295 | get |
344 | { | 296 | { |
345 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | 297 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) |
346 | // bc this is on heavy duty code paths | 298 | // bc this is on heavy duty code paths |
347 | // but for now we need to test the concept | 299 | // but for now we need to test the concept |
348 | AggregateGroupOrEveryOnePerms(); | 300 | AggregateDeepPerms(); |
349 | return m_EffectiveGroupOrEveryOnePerms; | 301 | return m_EffectiveOwnerPerms; |
350 | } | 302 | } |
351 | } | 303 | } |
352 | 304 | ||
353 | public void AggregateGroupOrEveryOnePerms() | 305 | // aggregates perms scanning parts and their contents |
306 | public void AggregateDeepPerms() | ||
354 | { | 307 | { |
355 | lock(PermissionsLock) | 308 | lock(PermissionsLock) |
356 | { | 309 | { |
357 | // get object everyone permissions | 310 | // aux |
358 | uint baseperms = (RootPart.EveryoneMask | RootPart.GroupMask) & (uint)PermissionMask.All; | 311 | const uint allmask = (uint)PermissionMask.AllEffective; |
312 | const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
313 | const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer); | ||
314 | |||
315 | uint baseOwnerPerms = RootPart.OwnerMask; | ||
316 | uint owner = baseOwnerPerms; | ||
317 | uint baseGroupPerms = RootPart.GroupMask; | ||
318 | uint group = baseGroupPerms; | ||
319 | uint baseEveryonePerms = RootPart.EveryoneMask; | ||
320 | uint everyone = baseEveryonePerms; | ||
359 | 321 | ||
360 | if(baseperms == 0) | ||
361 | { | ||
362 | m_EffectiveGroupOrEveryOnePerms = 0; | ||
363 | return; | ||
364 | } | ||
365 | |||
366 | uint current = baseperms; | ||
367 | SceneObjectPart[] parts = m_parts.GetArray(); | 322 | SceneObjectPart[] parts = m_parts.GetArray(); |
368 | for (int i = 0; i < parts.Length; i++) | 323 | for (int i = 0; i < parts.Length; i++) |
369 | { | 324 | { |
370 | SceneObjectPart part = parts[i]; | 325 | SceneObjectPart part = parts[i]; |
371 | part.Inventory.AggregateGroupOrEveryonePerms(ref current); | 326 | part.AggregateInnerPerms(); |
372 | if( current == 0) | 327 | owner &= part.AggregatedInnerOwnerPerms; |
373 | break; | 328 | group &= part.AggregatedInnerGroupPerms; |
329 | everyone &= part.AggregatedInnerEveryonePerms; | ||
374 | } | 330 | } |
375 | // recover modify and move | 331 | // recover modify and move |
376 | baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); | 332 | baseOwnerPerms &= movemodmask; |
377 | current |= baseperms; | 333 | owner |= baseOwnerPerms; |
378 | current &= (uint)PermissionMask.All; | 334 | if((owner & copytransfermast) == 0) |
379 | m_EffectiveGroupOrEveryOnePerms = current; | 335 | owner |= (uint)PermissionMask.Transfer; |
380 | } | 336 | owner &= allmask; |
381 | } | 337 | m_EffectiveOwnerPerms = owner; |
382 | 338 | ||
383 | private uint m_EffectiveOwnerPerms; | 339 | // recover modify and move |
384 | public uint EffectiveOwnerPerms | 340 | baseGroupPerms &= movemodmask; |
385 | { | 341 | group |= baseGroupPerms; |
386 | get | 342 | if((group & copytransfermast) == 0) |
387 | { | 343 | group |= (uint)PermissionMask.Transfer; |
388 | // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc) | 344 | group &= allmask; |
389 | // bc this is on heavy duty code paths | 345 | m_EffectiveGroupPerms = group; |
390 | // but for now we need to test the concept | 346 | |
391 | AggregateOwnerPerms(); | 347 | // recover move |
392 | return m_EffectiveOwnerPerms; | 348 | baseEveryonePerms &= (uint)PermissionMask.Move; |
349 | everyone |= baseEveryonePerms; | ||
350 | if((everyone & copytransfermast) == 0) // not much sense but as sl | ||
351 | everyone |= (uint)PermissionMask.Transfer; | ||
352 | everyone &= allmask; | ||
353 | m_EffectiveEveryOnePerms = everyone; | ||
393 | } | 354 | } |
394 | } | 355 | } |
395 | 356 | ||
396 | public void AggregateOwnerPerms() | 357 | // aggregates perms scanning parts, assuming their contents was already aggregated |
358 | public void AggregatePerms() | ||
397 | { | 359 | { |
398 | lock(PermissionsLock) | 360 | lock(PermissionsLock) |
399 | { | 361 | { |
400 | // get object everyone permissions | 362 | // aux |
401 | uint baseperms = RootPart.OwnerMask & (uint)PermissionMask.All; | 363 | const uint allmask = (uint)PermissionMask.AllEffective; |
364 | const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
365 | const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer); | ||
366 | |||
367 | uint baseOwnerPerms = RootPart.OwnerMask; | ||
368 | uint owner = baseOwnerPerms; | ||
369 | uint baseGroupPerms = RootPart.GroupMask; | ||
370 | uint group = baseGroupPerms; | ||
371 | uint baseEveryonePerms = RootPart.EveryoneMask; | ||
372 | uint everyone = baseEveryonePerms; | ||
402 | 373 | ||
403 | if(baseperms == 0) | ||
404 | { | ||
405 | m_EffectiveOwnerPerms = 0; | ||
406 | return; | ||
407 | } | ||
408 | |||
409 | uint current = baseperms; | ||
410 | SceneObjectPart[] parts = m_parts.GetArray(); | 374 | SceneObjectPart[] parts = m_parts.GetArray(); |
411 | for (int i = 0; i < parts.Length; i++) | 375 | for (int i = 0; i < parts.Length; i++) |
412 | { | 376 | { |
413 | SceneObjectPart part = parts[i]; | 377 | SceneObjectPart part = parts[i]; |
414 | part.Inventory.AggregateOwnerPerms(ref current); | 378 | owner &= part.AggregatedInnerOwnerPerms; |
415 | if( current == 0) | 379 | group &= part.AggregatedInnerGroupPerms; |
416 | break; | 380 | everyone &= part.AggregatedInnerEveryonePerms; |
417 | } | 381 | } |
418 | // recover modify and move | 382 | // recover modify and move |
419 | baseperms &= (uint)(PermissionMask.Move | PermissionMask.Modify ); | 383 | baseOwnerPerms &= movemodmask; |
420 | current |= baseperms; | 384 | owner |= baseOwnerPerms; |
421 | current &= (uint)PermissionMask.All; | 385 | if((owner & copytransfermast) == 0) |
422 | if((current & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0) | 386 | owner |= (uint)PermissionMask.Transfer; |
423 | current |= (uint)PermissionMask.Transfer; | 387 | owner &= allmask; |
424 | m_EffectiveOwnerPerms = current; | 388 | m_EffectiveOwnerPerms = owner; |
389 | |||
390 | // recover modify and move | ||
391 | baseGroupPerms &= movemodmask; | ||
392 | group |= baseGroupPerms; | ||
393 | if((group & copytransfermast) == 0) | ||
394 | group |= (uint)PermissionMask.Transfer; | ||
395 | group &= allmask; | ||
396 | m_EffectiveGroupPerms = group; | ||
397 | |||
398 | // recover move | ||
399 | baseEveryonePerms &= (uint)PermissionMask.Move; | ||
400 | everyone |= baseEveryonePerms; | ||
401 | if((everyone & copytransfermast) == 0) // not much sense but as sl | ||
402 | everyone |= (uint)PermissionMask.Transfer; | ||
403 | everyone &= allmask; | ||
404 | m_EffectiveEveryOnePerms = everyone; | ||
425 | } | 405 | } |
426 | } | 406 | } |
427 | 407 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 557b55e..9f99665 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2537,6 +2537,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2537 | return (uint)Flags | (uint)LocalFlags; | 2537 | return (uint)Flags | (uint)LocalFlags; |
2538 | } | 2538 | } |
2539 | 2539 | ||
2540 | // some of this lines need be moved to other place later | ||
2541 | |||
2542 | // effective permitions considering only this part inventory contents perms | ||
2543 | public uint AggregatedInnerOwnerPerms {get; private set; } | ||
2544 | public uint AggregatedInnerGroupPerms {get; private set; } | ||
2545 | public uint AggregatedInnerEveryonePerms {get; private set; } | ||
2546 | private object InnerPermsLock = new object(); | ||
2547 | |||
2548 | public void AggregateInnerPerms() | ||
2549 | { | ||
2550 | const uint mask = (uint)PermissionMask.AllEffective; | ||
2551 | |||
2552 | uint owner = mask; | ||
2553 | uint group = mask; | ||
2554 | uint everyone = mask; | ||
2555 | |||
2556 | lock(InnerPermsLock) // do we really need this? | ||
2557 | { | ||
2558 | if(Inventory != null) | ||
2559 | Inventory.AggregateInnerPerms(ref owner, ref group, ref everyone); | ||
2560 | |||
2561 | AggregatedInnerOwnerPerms = owner & mask; | ||
2562 | AggregatedInnerGroupPerms = group & mask; | ||
2563 | AggregatedInnerEveryonePerms = everyone & mask; | ||
2564 | } | ||
2565 | } | ||
2566 | |||
2540 | public Vector3 GetGeometricCenter() | 2567 | public Vector3 GetGeometricCenter() |
2541 | { | 2568 | { |
2542 | // this is not real geometric center but a average of positions relative to root prim acording to | 2569 | // this is not real geometric center but a average of positions relative to root prim acording to |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 636afac..a55936f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -1317,48 +1317,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | // reduce to minimal set | 1320 | public void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone) |
1321 | public void AggregateEveryOnePerms(ref uint current) | ||
1322 | { | 1321 | { |
1323 | foreach (TaskInventoryItem item in m_items.Values) | 1322 | foreach (TaskInventoryItem item in m_items.Values) |
1324 | { | 1323 | { |
1325 | current &= item.EveryonePermissions; | 1324 | owner &= item.CurrentPermissions; |
1326 | if(current == 0) | 1325 | group &= item.GroupPermissions; |
1327 | break; | 1326 | everyone &= item.EveryonePermissions; |
1328 | } | ||
1329 | } | ||
1330 | |||
1331 | public void AggregateGroupPerms(ref uint current) | ||
1332 | { | ||
1333 | foreach (TaskInventoryItem item in m_items.Values) | ||
1334 | { | ||
1335 | current &= item.GroupPermissions; | ||
1336 | if(current == 0) | ||
1337 | break; | ||
1338 | } | 1327 | } |
1339 | } | 1328 | } |
1340 | 1329 | ||
1341 | public void AggregateGroupOrEveryonePerms(ref uint current) | ||
1342 | { | ||
1343 | foreach (TaskInventoryItem item in m_items.Values) | ||
1344 | { | ||
1345 | current &= (item.GroupPermissions | item.EveryonePermissions); | ||
1346 | if(current == 0) | ||
1347 | break; | ||
1348 | } | ||
1349 | } | ||
1350 | |||
1351 | public void AggregateOwnerPerms(ref uint current) | ||
1352 | { | ||
1353 | foreach (TaskInventoryItem item in m_items.Values) | ||
1354 | { | ||
1355 | current &= item.CurrentPermissions; | ||
1356 | if(current == 0) | ||
1357 | break; | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1361 | |||
1362 | public uint MaskEffectivePermissions() | 1330 | public uint MaskEffectivePermissions() |
1363 | { | 1331 | { |
1364 | uint mask=0x7fffffff; | 1332 | uint mask=0x7fffffff; |