aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2010-02-02 03:49:00 +0000
committerMelanie2010-02-02 03:49:00 +0000
commit6478617c932e87bf091266dba2db4d73fcdd046f (patch)
treed84a062e159849bdb8d9d4ae398db966ef410594 /OpenSim/Region/Framework
parentminor: rename GetScriptPrimType() to GetPrimType() (diff)
downloadopensim-SC-6478617c932e87bf091266dba2db4d73fcdd046f.zip
opensim-SC-6478617c932e87bf091266dba2db4d73fcdd046f.tar.gz
opensim-SC-6478617c932e87bf091266dba2db4d73fcdd046f.tar.bz2
opensim-SC-6478617c932e87bf091266dba2db4d73fcdd046f.tar.xz
Revert "improve locking of m_items in SceneObjectPartInventory"
This reverts commit 968b9e160d70568fbdea5b190d1386e9431316e3.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs218
1 files changed, 85 insertions, 133 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 87c1a95..b37e1a2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -44,8 +44,6 @@ namespace OpenSim.Region.Framework.Scenes
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
48
49 private string m_inventoryFileName = String.Empty; 47 private string m_inventoryFileName = String.Empty;
50 private int m_inventoryFileNameSerial = 0; 48 private int m_inventoryFileNameSerial = 0;
51 49
@@ -272,12 +270,8 @@ namespace OpenSim.Region.Framework.Scenes
272 if (stateSource == 1 && // Prim crossing 270 if (stateSource == 1 && // Prim crossing
273 m_part.ParentGroup.Scene.m_trustBinaries) 271 m_part.ParentGroup.Scene.m_trustBinaries)
274 { 272 {
275 lock (m_items) 273 m_items[item.ItemID].PermsMask = 0;
276 { 274 m_items[item.ItemID].PermsGranter = UUID.Zero;
277 m_items[item.ItemID].PermsMask = 0;
278 m_items[item.ItemID].PermsGranter = UUID.Zero;
279 }
280
281 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 275 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
282 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 276 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
283 m_part.ParentGroup.AddActiveScriptCount(1); 277 m_part.ParentGroup.AddActiveScriptCount(1);
@@ -285,38 +279,33 @@ namespace OpenSim.Region.Framework.Scenes
285 return; 279 return;
286 } 280 }
287 281
288 m_part.ParentGroup.Scene.AssetService.Get( 282 m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset)
289 item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) 283 {
290 { 284 if (null == asset)
291 if (null == asset) 285 {
292 { 286 m_log.ErrorFormat(
293 m_log.ErrorFormat( 287 "[PRIM INVENTORY]: " +
294 "[PRIM INVENTORY]: " + 288 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
295 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 289 item.Name, item.ItemID, m_part.AbsolutePosition,
296 item.Name, item.ItemID, m_part.AbsolutePosition, 290 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
297 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 291 }
298 } 292 else
299 else 293 {
300 { 294 if (m_part.ParentGroup.m_savedScriptState != null)
301 if (m_part.ParentGroup.m_savedScriptState != null) 295 RestoreSavedScriptState(item.OldItemID, item.ItemID);
302 RestoreSavedScriptState(item.OldItemID, item.ItemID); 296 m_items[item.ItemID].PermsMask = 0;
303 297 m_items[item.ItemID].PermsGranter = UUID.Zero;
304 lock (m_items) 298 string script = Utils.BytesToString(asset.Data);
305 { 299 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
306 m_items[item.ItemID].PermsMask = 0; 300 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
307 m_items[item.ItemID].PermsGranter = UUID.Zero; 301 m_part.ParentGroup.AddActiveScriptCount(1);
308 } 302 m_part.ScheduleFullUpdate();
309 303 }
310 string script = Utils.BytesToString(asset.Data); 304 });
311 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
312 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
313 m_part.ParentGroup.AddActiveScriptCount(1);
314 m_part.ScheduleFullUpdate();
315 }
316 }
317 );
318 } 305 }
319 } 306 }
307
308 static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
320 309
321 private void RestoreSavedScriptState(UUID oldID, UUID newID) 310 private void RestoreSavedScriptState(UUID oldID, UUID newID)
322 { 311 {
@@ -408,15 +397,7 @@ namespace OpenSim.Region.Framework.Scenes
408 /// </param> 397 /// </param>
409 public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) 398 public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted)
410 { 399 {
411 bool scriptPresent = false; 400 if (m_items.ContainsKey(itemId))
412
413 lock (m_items)
414 {
415 if (m_items.ContainsKey(itemId))
416 scriptPresent = true;
417 }
418
419 if (scriptPresent)
420 { 401 {
421 if (!sceneObjectBeingDeleted) 402 if (!sceneObjectBeingDeleted)
422 m_part.RemoveScriptEvents(itemId); 403 m_part.RemoveScriptEvents(itemId);
@@ -488,13 +469,7 @@ namespace OpenSim.Region.Framework.Scenes
488 /// <param name="item"></param> 469 /// <param name="item"></param>
489 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) 470 public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
490 { 471 {
491 List<TaskInventoryItem> il; 472 List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values);
492
493 lock (m_items)
494 {
495 il = new List<TaskInventoryItem>(m_items.Values);
496 }
497
498 foreach (TaskInventoryItem i in il) 473 foreach (TaskInventoryItem i in il)
499 { 474 {
500 if (i.Name == item.Name) 475 if (i.Name == item.Name)
@@ -576,9 +551,7 @@ namespace OpenSim.Region.Framework.Scenes
576 public TaskInventoryItem GetInventoryItem(UUID itemId) 551 public TaskInventoryItem GetInventoryItem(UUID itemId)
577 { 552 {
578 TaskInventoryItem item; 553 TaskInventoryItem item;
579 554 m_items.TryGetValue(itemId, out item);
580 lock (m_items)
581 m_items.TryGetValue(itemId, out item);
582 555
583 return item; 556 return item;
584 } 557 }
@@ -904,61 +877,54 @@ namespace OpenSim.Region.Framework.Scenes
904 { 877 {
905 uint mask=0x7fffffff; 878 uint mask=0x7fffffff;
906 879
907 lock (m_items) 880 foreach (TaskInventoryItem item in m_items.Values)
908 { 881 {
909 foreach (TaskInventoryItem item in m_items.Values) 882 if (item.InvType != (int)InventoryType.Object)
910 { 883 {
911 if (item.InvType != (int)InventoryType.Object) 884 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
912 { 885 mask &= ~((uint)PermissionMask.Copy >> 13);
913 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) 886 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0)
914 mask &= ~((uint)PermissionMask.Copy >> 13); 887 mask &= ~((uint)PermissionMask.Transfer >> 13);
915 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) 888 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
916 mask &= ~((uint)PermissionMask.Transfer >> 13); 889 mask &= ~((uint)PermissionMask.Modify >> 13);
917 if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) 890 }
918 mask &= ~((uint)PermissionMask.Modify >> 13); 891 else
919 } 892 {
920 else 893 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
921 { 894 mask &= ~((uint)PermissionMask.Copy >> 13);
922 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 895 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
923 mask &= ~((uint)PermissionMask.Copy >> 13); 896 mask &= ~((uint)PermissionMask.Transfer >> 13);
924 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 897 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
925 mask &= ~((uint)PermissionMask.Transfer >> 13); 898 mask &= ~((uint)PermissionMask.Modify >> 13);
926 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
927 mask &= ~((uint)PermissionMask.Modify >> 13);
928 }
929
930 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
931 mask &= ~(uint)PermissionMask.Copy;
932 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
933 mask &= ~(uint)PermissionMask.Transfer;
934 if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0)
935 mask &= ~(uint)PermissionMask.Modify;
936 } 899 }
900
901 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
902 mask &= ~(uint)PermissionMask.Copy;
903 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
904 mask &= ~(uint)PermissionMask.Transfer;
905 if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0)
906 mask &= ~(uint)PermissionMask.Modify;
937 } 907 }
938
939 return mask; 908 return mask;
940 } 909 }
941 910
942 public void ApplyNextOwnerPermissions() 911 public void ApplyNextOwnerPermissions()
943 { 912 {
944 lock (m_items) 913 foreach (TaskInventoryItem item in m_items.Values)
945 { 914 {
946 foreach (TaskInventoryItem item in m_items.Values) 915 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
947 { 916 {
948 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 917 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
949 { 918 item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
950 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 919 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
951 item.CurrentPermissions &= ~(uint)PermissionMask.Copy; 920 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
952 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 921 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
953 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; 922 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
954 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 923 item.CurrentPermissions |= 8;
955 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
956 item.CurrentPermissions |= 8;
957 }
958 item.CurrentPermissions &= item.NextPermissions;
959 item.BasePermissions &= item.NextPermissions;
960 item.EveryonePermissions &= item.NextPermissions;
961 } 924 }
925 item.CurrentPermissions &= item.NextPermissions;
926 item.BasePermissions &= item.NextPermissions;
927 item.EveryonePermissions &= item.NextPermissions;
962 } 928 }
963 929
964 m_part.TriggerScriptChangedEvent(Changed.OWNER); 930 m_part.TriggerScriptChangedEvent(Changed.OWNER);
@@ -966,29 +932,22 @@ namespace OpenSim.Region.Framework.Scenes
966 932
967 public void ApplyGodPermissions(uint perms) 933 public void ApplyGodPermissions(uint perms)
968 { 934 {
969 lock (m_items) 935 foreach (TaskInventoryItem item in m_items.Values)
970 { 936 {
971 foreach (TaskInventoryItem item in m_items.Values) 937 item.CurrentPermissions = perms;
972 { 938 item.BasePermissions = perms;
973 item.CurrentPermissions = perms;
974 item.BasePermissions = perms;
975 }
976 } 939 }
977 } 940 }
978 941
979 public bool ContainsScripts() 942 public bool ContainsScripts()
980 { 943 {
981 lock (m_items) 944 foreach (TaskInventoryItem item in m_items.Values)
982 { 945 {
983 foreach (TaskInventoryItem item in m_items.Values) 946 if (item.InvType == (int)InventoryType.LSL)
984 { 947 {
985 if (item.InvType == (int)InventoryType.LSL) 948 return true;
986 {
987 return true;
988 }
989 } 949 }
990 } 950 }
991
992 return false; 951 return false;
993 } 952 }
994 953
@@ -996,11 +955,8 @@ namespace OpenSim.Region.Framework.Scenes
996 { 955 {
997 List<UUID> ret = new List<UUID>(); 956 List<UUID> ret = new List<UUID>();
998 957
999 lock (m_items) 958 foreach (TaskInventoryItem item in m_items.Values)
1000 { 959 ret.Add(item.ItemID);
1001 foreach (TaskInventoryItem item in m_items.Values)
1002 ret.Add(item.ItemID);
1003 }
1004 960
1005 return ret; 961 return ret;
1006 } 962 }
@@ -1013,30 +969,26 @@ namespace OpenSim.Region.Framework.Scenes
1013 if (engines == null) // No engine at all 969 if (engines == null) // No engine at all
1014 return ret; 970 return ret;
1015 971
1016 lock (m_items) 972 foreach (TaskInventoryItem item in m_items.Values)
1017 { 973 {
1018 foreach (TaskInventoryItem item in m_items.Values) 974 if (item.InvType == (int)InventoryType.LSL)
1019 { 975 {
1020 if (item.InvType == (int)InventoryType.LSL) 976 foreach (IScriptModule e in engines)
1021 { 977 {
1022 foreach (IScriptModule e in engines) 978 if (e != null)
1023 { 979 {
1024 if (e != null) 980 string n = e.GetXMLState(item.ItemID);
981 if (n != String.Empty)
1025 { 982 {
1026 string n = e.GetXMLState(item.ItemID); 983 if (!ret.ContainsKey(item.ItemID))
1027 if (n != String.Empty) 984 ret[item.ItemID] = n;
1028 { 985 break;
1029 if (!ret.ContainsKey(item.ItemID))
1030 ret[item.ItemID] = n;
1031 break;
1032 }
1033 } 986 }
1034 } 987 }
1035 } 988 }
1036 } 989 }
1037 } 990 }
1038
1039 return ret; 991 return ret;
1040 } 992 }
1041 } 993 }
1042} \ No newline at end of file 994}