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