diff options
author | Melanie | 2009-11-24 16:00:45 +0000 |
---|---|---|
committer | Melanie | 2009-11-24 16:00:45 +0000 |
commit | 81f7e9b462ae1596f1625087a14ba37cca59865b (patch) | |
tree | a7b3ddba3948d2b2e98e3271c8db87379137dffe | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Removed some extra debug chatter (diff) | |
download | opensim-SC-81f7e9b462ae1596f1625087a14ba37cca59865b.zip opensim-SC-81f7e9b462ae1596f1625087a14ba37cca59865b.tar.gz opensim-SC-81f7e9b462ae1596f1625087a14ba37cca59865b.tar.bz2 opensim-SC-81f7e9b462ae1596f1625087a14ba37cca59865b.tar.xz |
Merge branch 'careminster' of kitto@tor.k-grid.com:/home/kitto/opensim into careminster
Diffstat (limited to '')
14 files changed, 848 insertions, 619 deletions
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 25ae6b0..efe5f0c 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs | |||
@@ -27,9 +27,12 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
30 | using System.Xml; | 32 | using System.Xml; |
31 | using System.Xml.Schema; | 33 | using System.Xml.Schema; |
32 | using System.Xml.Serialization; | 34 | using System.Xml.Serialization; |
35 | using log4net; | ||
33 | using OpenMetaverse; | 36 | using OpenMetaverse; |
34 | 37 | ||
35 | namespace OpenSim.Framework | 38 | namespace OpenSim.Framework |
@@ -45,6 +48,105 @@ namespace OpenSim.Framework | |||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 49 | ||
47 | private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); | 50 | private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private Thread LockedByThread; | ||
54 | /// <value> | ||
55 | /// An advanced lock for inventory data | ||
56 | /// </value> | ||
57 | private System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
58 | |||
59 | /// <summary> | ||
60 | /// Are we readlocked by the calling thread? | ||
61 | /// </summary> | ||
62 | public bool IsReadLockedByMe() | ||
63 | { | ||
64 | if (m_itemLock.RecursiveReadCount > 0) | ||
65 | { | ||
66 | return true; | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | return false; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Lock our inventory list for reading (many can read, one can write) | ||
76 | /// </summary> | ||
77 | public void LockItemsForRead(bool locked) | ||
78 | { | ||
79 | if (locked) | ||
80 | { | ||
81 | if (m_itemLock.IsWriteLockHeld && LockedByThread != null) | ||
82 | { | ||
83 | if (!LockedByThread.IsAlive) | ||
84 | { | ||
85 | //Locked by dead thread, reset. | ||
86 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | if (m_itemLock.RecursiveReadCount > 0) | ||
91 | { | ||
92 | m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
93 | m_itemLock.ExitReadLock(); | ||
94 | } | ||
95 | if (m_itemLock.RecursiveWriteCount > 0) | ||
96 | { | ||
97 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
98 | m_itemLock.ExitWriteLock(); | ||
99 | } | ||
100 | |||
101 | while (!m_itemLock.TryEnterReadLock(60000)) | ||
102 | { | ||
103 | m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
104 | if (m_itemLock.IsWriteLockHeld) | ||
105 | { | ||
106 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | else | ||
111 | { | ||
112 | m_itemLock.ExitReadLock(); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | /// <summary> | ||
117 | /// Lock our inventory list for writing (many can read, one can write) | ||
118 | /// </summary> | ||
119 | public void LockItemsForWrite(bool locked) | ||
120 | { | ||
121 | if (locked) | ||
122 | { | ||
123 | //Enter a write lock, wait indefinately for one to open. | ||
124 | if (m_itemLock.RecursiveReadCount > 0) | ||
125 | { | ||
126 | m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
127 | m_itemLock.ExitReadLock(); | ||
128 | } | ||
129 | if (m_itemLock.RecursiveWriteCount > 0) | ||
130 | { | ||
131 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
132 | m_itemLock.ExitWriteLock(); | ||
133 | } | ||
134 | while (!m_itemLock.TryEnterWriteLock(60000)) | ||
135 | { | ||
136 | m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
137 | if (m_itemLock.IsWriteLockHeld) | ||
138 | { | ||
139 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | LockedByThread = Thread.CurrentThread; | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | m_itemLock.ExitWriteLock(); | ||
148 | } | ||
149 | } | ||
48 | 150 | ||
49 | #region ICloneable Members | 151 | #region ICloneable Members |
50 | 152 | ||
@@ -52,13 +154,12 @@ namespace OpenSim.Framework | |||
52 | { | 154 | { |
53 | TaskInventoryDictionary clone = new TaskInventoryDictionary(); | 155 | TaskInventoryDictionary clone = new TaskInventoryDictionary(); |
54 | 156 | ||
55 | lock (this) | 157 | m_itemLock.EnterReadLock(); |
158 | foreach (UUID uuid in Keys) | ||
56 | { | 159 | { |
57 | foreach (UUID uuid in Keys) | 160 | clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone()); |
58 | { | ||
59 | clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone()); | ||
60 | } | ||
61 | } | 161 | } |
162 | m_itemLock.ExitReadLock(); | ||
62 | 163 | ||
63 | return clone; | 164 | return clone; |
64 | } | 165 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index cd59bdb..5c24f03 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -266,25 +266,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
266 | } | 266 | } |
267 | 267 | ||
268 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 268 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
269 | 269 | if (c.Scene != null) | |
270 | ((Scene)c.Scene).ForEachScenePresence( | 270 | { |
271 | delegate(ScenePresence presence) | 271 | ((Scene)c.Scene).ForEachScenePresence |
272 | { | 272 | ( |
273 | // ignore chat from child agents | 273 | delegate(ScenePresence presence) |
274 | if (presence.IsChildAgent) return; | 274 | { |
275 | 275 | // ignore chat from child agents | |
276 | IClientAPI client = presence.ControllingClient; | 276 | if (presence.IsChildAgent) return; |
277 | 277 | ||
278 | // don't forward SayOwner chat from objects to | 278 | IClientAPI client = presence.ControllingClient; |
279 | // non-owner agents | 279 | |
280 | if ((c.Type == ChatTypeEnum.Owner) && | 280 | // don't forward SayOwner chat from objects to |
281 | (null != c.SenderObject) && | 281 | // non-owner agents |
282 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 282 | if ((c.Type == ChatTypeEnum.Owner) && |
283 | return; | 283 | (null != c.SenderObject) && |
284 | 284 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | |
285 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 285 | return; |
286 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 286 | |
287 | }); | 287 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
288 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | ||
289 | } | ||
290 | ); | ||
291 | } | ||
288 | } | 292 | } |
289 | 293 | ||
290 | 294 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..b60b32b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -389,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
389 | { | 389 | { |
390 | // Check if this is ours to handle | 390 | // Check if this is ours to handle |
391 | // | 391 | // |
392 | m_log.Info("OnFridInstantMessage"); | 392 | //m_log.Info("OnFridInstantMessage"); |
393 | if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) | 393 | if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) |
394 | return; | 394 | return; |
395 | 395 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 70a225e..f204faf 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -246,21 +246,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
246 | // Fix ownership/creator of inventory items | 246 | // Fix ownership/creator of inventory items |
247 | // Not doing so results in inventory items | 247 | // Not doing so results in inventory items |
248 | // being no copy/no mod for everyone | 248 | // being no copy/no mod for everyone |
249 | lock (part.TaskInventory) | 249 | part.TaskInventory.LockItemsForRead(true); |
250 | TaskInventoryDictionary inv = part.TaskInventory; | ||
251 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | ||
250 | { | 252 | { |
251 | TaskInventoryDictionary inv = part.TaskInventory; | 253 | if (!ResolveUserUuid(kvp.Value.OwnerID)) |
252 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | ||
253 | { | 254 | { |
254 | if (!ResolveUserUuid(kvp.Value.OwnerID)) | 255 | kvp.Value.OwnerID = masterAvatarId; |
255 | { | 256 | } |
256 | kvp.Value.OwnerID = masterAvatarId; | 257 | if (!ResolveUserUuid(kvp.Value.CreatorID)) |
257 | } | 258 | { |
258 | if (!ResolveUserUuid(kvp.Value.CreatorID)) | 259 | kvp.Value.CreatorID = masterAvatarId; |
259 | { | ||
260 | kvp.Value.CreatorID = masterAvatarId; | ||
261 | } | ||
262 | } | 260 | } |
263 | } | 261 | } |
262 | part.TaskInventory.LockItemsForRead(false); | ||
264 | } | 263 | } |
265 | 264 | ||
266 | if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) | 265 | if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 66fb918..83208e9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -840,8 +840,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
840 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 840 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
841 | { | 841 | { |
842 | SceneObjectPart part = GetSceneObjectPart(localID); | 842 | SceneObjectPart part = GetSceneObjectPart(localID); |
843 | SceneObjectGroup group = part.ParentGroup; | 843 | SceneObjectGroup group = null; |
844 | if (group != null) | 844 | if (part != null) |
845 | { | ||
846 | group = part.ParentGroup; | ||
847 | } | ||
848 | if (part != null && group != null) | ||
845 | { | 849 | { |
846 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | 850 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
847 | if (item == null) | 851 | if (item == null) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cdec135..bbece2f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -389,12 +389,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | } | 389 | } |
390 | 390 | ||
391 | /// <value> | 391 | /// <value> |
392 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 392 | /// Get the inventory list |
393 | /// </value> | 393 | /// </value> |
394 | public TaskInventoryDictionary TaskInventory | 394 | public TaskInventoryDictionary TaskInventory |
395 | { | 395 | { |
396 | get { return m_inventory.Items; } | 396 | get { |
397 | set { m_inventory.Items = value; } | 397 | return m_inventory.Items; |
398 | } | ||
399 | set { | ||
400 | m_inventory.Items = value; | ||
401 | } | ||
398 | } | 402 | } |
399 | 403 | ||
400 | public uint ObjectFlags | 404 | public uint ObjectFlags |
@@ -2101,17 +2105,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2101 | //Trys to fetch sound id from prim's inventory. | 2105 | //Trys to fetch sound id from prim's inventory. |
2102 | //Prim's inventory doesn't support non script items yet | 2106 | //Prim's inventory doesn't support non script items yet |
2103 | 2107 | ||
2104 | lock (TaskInventory) | 2108 | TaskInventory.LockItemsForRead(true); |
2109 | |||
2110 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2105 | { | 2111 | { |
2106 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2112 | if (item.Value.Name == sound) |
2107 | { | 2113 | { |
2108 | if (item.Value.Name == sound) | 2114 | soundID = item.Value.ItemID; |
2109 | { | 2115 | break; |
2110 | soundID = item.Value.ItemID; | ||
2111 | break; | ||
2112 | } | ||
2113 | } | 2116 | } |
2114 | } | 2117 | } |
2118 | |||
2119 | TaskInventory.LockItemsForRead(false); | ||
2115 | } | 2120 | } |
2116 | 2121 | ||
2117 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); | 2122 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); |
@@ -2457,17 +2462,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2457 | if (!UUID.TryParse(sound, out soundID)) | 2462 | if (!UUID.TryParse(sound, out soundID)) |
2458 | { | 2463 | { |
2459 | // search sound file from inventory | 2464 | // search sound file from inventory |
2460 | lock (TaskInventory) | 2465 | TaskInventory.LockItemsForRead(true); |
2466 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2461 | { | 2467 | { |
2462 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2468 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) |
2463 | { | 2469 | { |
2464 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | 2470 | soundID = item.Value.ItemID; |
2465 | { | 2471 | break; |
2466 | soundID = item.Value.ItemID; | ||
2467 | break; | ||
2468 | } | ||
2469 | } | 2472 | } |
2470 | } | 2473 | } |
2474 | TaskInventory.LockItemsForRead(false); | ||
2471 | } | 2475 | } |
2472 | 2476 | ||
2473 | if (soundID == UUID.Zero) | 2477 | if (soundID == UUID.Zero) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f4ca877..abb04cd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
80 | /// </value> | 80 | /// </value> |
81 | protected internal TaskInventoryDictionary Items | 81 | protected internal TaskInventoryDictionary Items |
82 | { | 82 | { |
83 | get { return m_items; } | 83 | get { |
84 | return m_items; | ||
85 | } | ||
84 | set | 86 | set |
85 | { | 87 | { |
86 | m_items = value; | 88 | m_items = value; |
@@ -116,22 +118,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | /// <param name="linkNum">Link number for the part</param> | 118 | /// <param name="linkNum">Link number for the part</param> |
117 | public void ResetInventoryIDs() | 119 | public void ResetInventoryIDs() |
118 | { | 120 | { |
119 | lock (Items) | 121 | m_items.LockItemsForWrite(true); |
122 | |||
123 | if (0 == Items.Count) | ||
120 | { | 124 | { |
121 | if (0 == Items.Count) | 125 | m_items.LockItemsForWrite(false); |
122 | return; | 126 | return; |
127 | } | ||
123 | 128 | ||
124 | HasInventoryChanged = true; | 129 | HasInventoryChanged = true; |
125 | m_part.ParentGroup.HasGroupChanged = true; | 130 | m_part.ParentGroup.HasGroupChanged = true; |
126 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 131 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
127 | Items.Clear(); | 132 | Items.Clear(); |
128 | 133 | ||
129 | foreach (TaskInventoryItem item in items) | 134 | foreach (TaskInventoryItem item in items) |
130 | { | 135 | { |
131 | item.ResetIDs(m_part.UUID); | 136 | item.ResetIDs(m_part.UUID); |
132 | Items.Add(item.ItemID, item); | 137 | Items.Add(item.ItemID, item); |
133 | } | ||
134 | } | 138 | } |
139 | m_items.LockItemsForWrite(false); | ||
135 | } | 140 | } |
136 | 141 | ||
137 | /// <summary> | 142 | /// <summary> |
@@ -140,25 +145,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
140 | /// <param name="ownerId"></param> | 145 | /// <param name="ownerId"></param> |
141 | public void ChangeInventoryOwner(UUID ownerId) | 146 | public void ChangeInventoryOwner(UUID ownerId) |
142 | { | 147 | { |
143 | lock (Items) | 148 | m_items.LockItemsForWrite(true); |
149 | if (0 == Items.Count) | ||
144 | { | 150 | { |
145 | if (0 == Items.Count) | 151 | m_items.LockItemsForWrite(false); |
146 | { | 152 | return; |
147 | return; | 153 | } |
148 | } | ||
149 | 154 | ||
150 | HasInventoryChanged = true; | 155 | HasInventoryChanged = true; |
151 | m_part.ParentGroup.HasGroupChanged = true; | 156 | m_part.ParentGroup.HasGroupChanged = true; |
152 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 157 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
153 | foreach (TaskInventoryItem item in items) | 158 | foreach (TaskInventoryItem item in items) |
159 | { | ||
160 | if (ownerId != item.OwnerID) | ||
154 | { | 161 | { |
155 | if (ownerId != item.OwnerID) | 162 | item.LastOwnerID = item.OwnerID; |
156 | { | 163 | item.OwnerID = ownerId; |
157 | item.LastOwnerID = item.OwnerID; | ||
158 | item.OwnerID = ownerId; | ||
159 | } | ||
160 | } | 164 | } |
161 | } | 165 | } |
166 | m_items.LockItemsForWrite(false); | ||
162 | } | 167 | } |
163 | 168 | ||
164 | /// <summary> | 169 | /// <summary> |
@@ -167,24 +172,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | /// <param name="groupID"></param> | 172 | /// <param name="groupID"></param> |
168 | public void ChangeInventoryGroup(UUID groupID) | 173 | public void ChangeInventoryGroup(UUID groupID) |
169 | { | 174 | { |
170 | lock (Items) | 175 | m_items.LockItemsForWrite(true); |
176 | if (0 == Items.Count) | ||
171 | { | 177 | { |
172 | if (0 == Items.Count) | 178 | m_items.LockItemsForWrite(false); |
173 | { | 179 | return; |
174 | return; | 180 | } |
175 | } | ||
176 | 181 | ||
177 | HasInventoryChanged = true; | 182 | HasInventoryChanged = true; |
178 | m_part.ParentGroup.HasGroupChanged = true; | 183 | m_part.ParentGroup.HasGroupChanged = true; |
179 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 184 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
180 | foreach (TaskInventoryItem item in items) | 185 | foreach (TaskInventoryItem item in items) |
186 | { | ||
187 | if (groupID != item.GroupID) | ||
181 | { | 188 | { |
182 | if (groupID != item.GroupID) | 189 | item.GroupID = groupID; |
183 | { | ||
184 | item.GroupID = groupID; | ||
185 | } | ||
186 | } | 190 | } |
187 | } | 191 | } |
192 | m_items.LockItemsForWrite(false); | ||
188 | } | 193 | } |
189 | 194 | ||
190 | /// <summary> | 195 | /// <summary> |
@@ -192,14 +197,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | /// </summary> | 197 | /// </summary> |
193 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 198 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
194 | { | 199 | { |
195 | lock (m_items) | 200 | Items.LockItemsForRead(true); |
201 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
202 | Items.LockItemsForRead(false); | ||
203 | foreach (TaskInventoryItem item in items) | ||
196 | { | 204 | { |
197 | foreach (TaskInventoryItem item in Items.Values) | 205 | if ((int)InventoryType.LSL == item.InvType) |
198 | { | 206 | { |
199 | if ((int)InventoryType.LSL == item.InvType) | 207 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
200 | { | ||
201 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
202 | } | ||
203 | } | 208 | } |
204 | } | 209 | } |
205 | } | 210 | } |
@@ -209,17 +214,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | /// </summary> | 214 | /// </summary> |
210 | public void RemoveScriptInstances() | 215 | public void RemoveScriptInstances() |
211 | { | 216 | { |
212 | lock (Items) | 217 | Items.LockItemsForRead(true); |
218 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
219 | Items.LockItemsForRead(false); | ||
220 | |||
221 | foreach (TaskInventoryItem item in items) | ||
213 | { | 222 | { |
214 | foreach (TaskInventoryItem item in Items.Values) | 223 | if ((int)InventoryType.LSL == item.InvType) |
215 | { | 224 | { |
216 | if ((int)InventoryType.LSL == item.InvType) | 225 | RemoveScriptInstance(item.ItemID); |
217 | { | 226 | m_part.RemoveScriptEvents(item.ItemID); |
218 | RemoveScriptInstance(item.ItemID); | ||
219 | m_part.RemoveScriptEvents(item.ItemID); | ||
220 | } | ||
221 | } | 227 | } |
222 | } | 228 | } |
229 | |||
230 | |||
223 | } | 231 | } |
224 | 232 | ||
225 | /// <summary> | 233 | /// <summary> |
@@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | if (stateSource == 1 && // Prim crossing | 252 | if (stateSource == 1 && // Prim crossing |
245 | m_part.ParentGroup.Scene.m_trustBinaries) | 253 | m_part.ParentGroup.Scene.m_trustBinaries) |
246 | { | 254 | { |
255 | m_items.LockItemsForWrite(true); | ||
247 | m_items[item.ItemID].PermsMask = 0; | 256 | m_items[item.ItemID].PermsMask = 0; |
248 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 257 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
258 | m_items.LockItemsForWrite(false); | ||
249 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 259 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
250 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 260 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
251 | m_part.ParentGroup.AddActiveScriptCount(1); | 261 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -266,8 +276,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | { | 276 | { |
267 | if (m_part.ParentGroup.m_savedScriptState != null) | 277 | if (m_part.ParentGroup.m_savedScriptState != null) |
268 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 278 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
279 | m_items.LockItemsForWrite(true); | ||
269 | m_items[item.ItemID].PermsMask = 0; | 280 | m_items[item.ItemID].PermsMask = 0; |
270 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 281 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
282 | m_items.LockItemsForWrite(false); | ||
271 | string script = Utils.BytesToString(asset.Data); | 283 | string script = Utils.BytesToString(asset.Data); |
272 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 284 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
273 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 285 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -302,20 +314,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
302 | /// </param> | 314 | /// </param> |
303 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 315 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
304 | { | 316 | { |
305 | lock (m_items) | 317 | m_items.LockItemsForRead(true); |
318 | if (m_items.ContainsKey(itemId)) | ||
306 | { | 319 | { |
307 | if (m_items.ContainsKey(itemId)) | 320 | TaskInventoryItem item = m_items[itemId]; |
308 | { | 321 | m_items.LockItemsForRead(false); |
309 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 322 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
310 | } | ||
311 | else | ||
312 | { | ||
313 | m_log.ErrorFormat( | ||
314 | "[PRIM INVENTORY]: " + | ||
315 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
316 | itemId, m_part.Name, m_part.UUID); | ||
317 | } | ||
318 | } | 323 | } |
324 | else | ||
325 | { | ||
326 | m_items.LockItemsForRead(false); | ||
327 | m_log.ErrorFormat( | ||
328 | "[PRIM INVENTORY]: " + | ||
329 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
330 | itemId, m_part.Name, m_part.UUID); | ||
331 | } | ||
332 | |||
319 | } | 333 | } |
320 | 334 | ||
321 | /// <summary> | 335 | /// <summary> |
@@ -346,11 +360,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
346 | /// <returns></returns> | 360 | /// <returns></returns> |
347 | private bool InventoryContainsName(string name) | 361 | private bool InventoryContainsName(string name) |
348 | { | 362 | { |
349 | foreach (TaskInventoryItem item in Items.Values) | 363 | m_items.LockItemsForRead(true); |
364 | foreach (TaskInventoryItem item in m_items.Values) | ||
350 | { | 365 | { |
351 | if (item.Name == name) | 366 | if (item.Name == name) |
367 | { | ||
368 | m_items.LockItemsForRead(false); | ||
352 | return true; | 369 | return true; |
370 | } | ||
353 | } | 371 | } |
372 | m_items.LockItemsForRead(false); | ||
354 | return false; | 373 | return false; |
355 | } | 374 | } |
356 | 375 | ||
@@ -392,7 +411,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
392 | /// <param name="item"></param> | 411 | /// <param name="item"></param> |
393 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 412 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
394 | { | 413 | { |
414 | m_items.LockItemsForRead(true); | ||
395 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | 415 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); |
416 | m_items.LockItemsForRead(false); | ||
396 | foreach (TaskInventoryItem i in il) | 417 | foreach (TaskInventoryItem i in il) |
397 | { | 418 | { |
398 | if (i.Name == item.Name) | 419 | if (i.Name == item.Name) |
@@ -429,15 +450,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
429 | item.ParentPartID = m_part.UUID; | 450 | item.ParentPartID = m_part.UUID; |
430 | item.Name = name; | 451 | item.Name = name; |
431 | 452 | ||
432 | lock (m_items) | 453 | m_items.LockItemsForWrite(true); |
433 | { | 454 | m_items.Add(item.ItemID, item); |
434 | m_items.Add(item.ItemID, item); | 455 | m_items.LockItemsForWrite(false); |
435 | |||
436 | if (allowedDrop) | 456 | if (allowedDrop) |
437 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 457 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
438 | else | 458 | else |
439 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 459 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
440 | } | 460 | |
441 | 461 | ||
442 | m_inventorySerial++; | 462 | m_inventorySerial++; |
443 | //m_inventorySerial += 2; | 463 | //m_inventorySerial += 2; |
@@ -454,14 +474,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
454 | /// <param name="items"></param> | 474 | /// <param name="items"></param> |
455 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 475 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
456 | { | 476 | { |
457 | lock (m_items) | 477 | m_items.LockItemsForWrite(true); |
478 | foreach (TaskInventoryItem item in items) | ||
458 | { | 479 | { |
459 | foreach (TaskInventoryItem item in items) | 480 | m_items.Add(item.ItemID, item); |
460 | { | 481 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
461 | m_items.Add(item.ItemID, item); | ||
462 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
463 | } | ||
464 | } | 482 | } |
483 | m_items.LockItemsForWrite(false); | ||
465 | 484 | ||
466 | m_inventorySerial++; | 485 | m_inventorySerial++; |
467 | } | 486 | } |
@@ -474,8 +493,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
474 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 493 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
475 | { | 494 | { |
476 | TaskInventoryItem item; | 495 | TaskInventoryItem item; |
496 | m_items.LockItemsForRead(true); | ||
477 | m_items.TryGetValue(itemId, out item); | 497 | m_items.TryGetValue(itemId, out item); |
478 | 498 | m_items.LockItemsForRead(false); | |
479 | return item; | 499 | return item; |
480 | } | 500 | } |
481 | 501 | ||
@@ -487,45 +507,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 507 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
488 | public bool UpdateInventoryItem(TaskInventoryItem item) | 508 | public bool UpdateInventoryItem(TaskInventoryItem item) |
489 | { | 509 | { |
490 | lock (m_items) | 510 | m_items.LockItemsForWrite(true); |
511 | |||
512 | if (m_items.ContainsKey(item.ItemID)) | ||
491 | { | 513 | { |
492 | if (m_items.ContainsKey(item.ItemID)) | 514 | item.ParentID = m_part.UUID; |
515 | item.ParentPartID = m_part.UUID; | ||
516 | item.Flags = m_items[item.ItemID].Flags; | ||
517 | if (item.AssetID == UUID.Zero) | ||
493 | { | 518 | { |
494 | item.ParentID = m_part.UUID; | 519 | item.AssetID = m_items[item.ItemID].AssetID; |
495 | item.ParentPartID = m_part.UUID; | 520 | } |
496 | item.Flags = m_items[item.ItemID].Flags; | 521 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
497 | if (item.AssetID == UUID.Zero) | 522 | { |
498 | { | 523 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
499 | item.AssetID = m_items[item.ItemID].AssetID; | ||
500 | } | ||
501 | else if ((InventoryType)item.Type == InventoryType.Notecard) | ||
502 | { | ||
503 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); | ||
504 | 524 | ||
505 | if (presence != null) | 525 | if (presence != null) |
506 | { | 526 | { |
507 | presence.ControllingClient.SendAgentAlertMessage( | 527 | presence.ControllingClient.SendAgentAlertMessage( |
508 | "Notecard saved", false); | 528 | "Notecard saved", false); |
509 | } | ||
510 | } | 529 | } |
530 | } | ||
511 | 531 | ||
512 | m_items[item.ItemID] = item; | 532 | m_items[item.ItemID] = item; |
513 | m_inventorySerial++; | 533 | m_inventorySerial++; |
514 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 534 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
515 | |||
516 | HasInventoryChanged = true; | ||
517 | m_part.ParentGroup.HasGroupChanged = true; | ||
518 | 535 | ||
519 | return true; | 536 | HasInventoryChanged = true; |
520 | } | 537 | m_part.ParentGroup.HasGroupChanged = true; |
521 | else | 538 | m_items.LockItemsForWrite(false); |
522 | { | 539 | return true; |
523 | m_log.ErrorFormat( | 540 | } |
524 | "[PRIM INVENTORY]: " + | 541 | else |
525 | "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | 542 | { |
526 | item.ItemID, m_part.Name, m_part.UUID); | 543 | m_log.ErrorFormat( |
527 | } | 544 | "[PRIM INVENTORY]: " + |
545 | "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
546 | item.ItemID, m_part.Name, m_part.UUID); | ||
528 | } | 547 | } |
548 | m_items.LockItemsForWrite(false); | ||
529 | 549 | ||
530 | return false; | 550 | return false; |
531 | } | 551 | } |
@@ -538,51 +558,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
538 | /// in this prim's inventory.</returns> | 558 | /// in this prim's inventory.</returns> |
539 | public int RemoveInventoryItem(UUID itemID) | 559 | public int RemoveInventoryItem(UUID itemID) |
540 | { | 560 | { |
541 | lock (m_items) | 561 | m_items.LockItemsForRead(true); |
562 | |||
563 | if (m_items.ContainsKey(itemID)) | ||
542 | { | 564 | { |
543 | if (m_items.ContainsKey(itemID)) | 565 | int type = m_items[itemID].InvType; |
566 | m_items.LockItemsForRead(false); | ||
567 | if (type == 10) // Script | ||
544 | { | 568 | { |
545 | int type = m_items[itemID].InvType; | 569 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
546 | if (type == 10) // Script | 570 | } |
547 | { | 571 | m_items.LockItemsForWrite(true); |
548 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 572 | m_items.Remove(itemID); |
549 | } | 573 | m_items.LockItemsForWrite(false); |
550 | m_items.Remove(itemID); | 574 | m_inventorySerial++; |
551 | m_inventorySerial++; | 575 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
552 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
553 | |||
554 | HasInventoryChanged = true; | ||
555 | m_part.ParentGroup.HasGroupChanged = true; | ||
556 | 576 | ||
557 | int scriptcount = 0; | 577 | HasInventoryChanged = true; |
558 | lock (m_items) | 578 | m_part.ParentGroup.HasGroupChanged = true; |
559 | { | ||
560 | foreach (TaskInventoryItem item in m_items.Values) | ||
561 | { | ||
562 | if (item.Type == 10) | ||
563 | { | ||
564 | scriptcount++; | ||
565 | } | ||
566 | } | ||
567 | } | ||
568 | 579 | ||
569 | if (scriptcount <= 0) | 580 | int scriptcount = 0; |
581 | m_items.LockItemsForRead(true); | ||
582 | foreach (TaskInventoryItem item in m_items.Values) | ||
583 | { | ||
584 | if (item.Type == 10) | ||
570 | { | 585 | { |
571 | m_part.RemFlag(PrimFlags.Scripted); | 586 | scriptcount++; |
572 | } | 587 | } |
573 | |||
574 | m_part.ScheduleFullUpdate(); | ||
575 | |||
576 | return type; | ||
577 | } | 588 | } |
578 | else | 589 | m_items.LockItemsForRead(false); |
590 | |||
591 | |||
592 | if (scriptcount <= 0) | ||
579 | { | 593 | { |
580 | m_log.ErrorFormat( | 594 | m_part.RemFlag(PrimFlags.Scripted); |
581 | "[PRIM INVENTORY]: " + | ||
582 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
583 | itemID, m_part.Name, m_part.UUID); | ||
584 | } | 595 | } |
596 | |||
597 | m_part.ScheduleFullUpdate(); | ||
598 | |||
599 | return type; | ||
600 | } | ||
601 | else | ||
602 | { | ||
603 | m_log.ErrorFormat( | ||
604 | "[PRIM INVENTORY]: " + | ||
605 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
606 | itemID, m_part.Name, m_part.UUID); | ||
585 | } | 607 | } |
608 | m_items.LockItemsForWrite(false); | ||
586 | 609 | ||
587 | return -1; | 610 | return -1; |
588 | } | 611 | } |
@@ -635,52 +658,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | // isn't available (such as drag from prim inventory to agent inventory) | 658 | // isn't available (such as drag from prim inventory to agent inventory) |
636 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 659 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
637 | 660 | ||
638 | lock (m_items) | 661 | m_items.LockItemsForRead(true); |
662 | |||
663 | foreach (TaskInventoryItem item in m_items.Values) | ||
639 | { | 664 | { |
640 | foreach (TaskInventoryItem item in m_items.Values) | 665 | UUID ownerID = item.OwnerID; |
641 | { | 666 | uint everyoneMask = 0; |
642 | UUID ownerID = item.OwnerID; | 667 | uint baseMask = item.BasePermissions; |
643 | uint everyoneMask = 0; | 668 | uint ownerMask = item.CurrentPermissions; |
644 | uint baseMask = item.BasePermissions; | ||
645 | uint ownerMask = item.CurrentPermissions; | ||
646 | 669 | ||
647 | invString.AddItemStart(); | 670 | invString.AddItemStart(); |
648 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 671 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
649 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 672 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
650 | 673 | ||
651 | invString.AddPermissionsStart(); | 674 | invString.AddPermissionsStart(); |
652 | 675 | ||
653 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 676 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
654 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 677 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
655 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 678 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); |
656 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 679 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
657 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 680 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
658 | 681 | ||
659 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 682 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
660 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 683 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
661 | 684 | ||
662 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 685 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
663 | 686 | ||
664 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 687 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
665 | invString.AddSectionEnd(); | 688 | invString.AddSectionEnd(); |
666 | 689 | ||
667 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 690 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
668 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 691 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
669 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 692 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
670 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 693 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
671 | 694 | ||
672 | invString.AddSaleStart(); | 695 | invString.AddSaleStart(); |
673 | invString.AddNameValueLine("sale_type", "not"); | 696 | invString.AddNameValueLine("sale_type", "not"); |
674 | invString.AddNameValueLine("sale_price", "0"); | 697 | invString.AddNameValueLine("sale_price", "0"); |
675 | invString.AddSectionEnd(); | 698 | invString.AddSectionEnd(); |
676 | 699 | ||
677 | invString.AddNameValueLine("name", item.Name + "|"); | 700 | invString.AddNameValueLine("name", item.Name + "|"); |
678 | invString.AddNameValueLine("desc", item.Description + "|"); | 701 | invString.AddNameValueLine("desc", item.Description + "|"); |
679 | 702 | ||
680 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 703 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
681 | invString.AddSectionEnd(); | 704 | invString.AddSectionEnd(); |
682 | } | ||
683 | } | 705 | } |
706 | int count = m_items.Count; | ||
707 | m_items.LockItemsForRead(false); | ||
684 | 708 | ||
685 | fileData = Utils.StringToBytes(invString.BuildString); | 709 | fileData = Utils.StringToBytes(invString.BuildString); |
686 | 710 | ||
@@ -701,10 +725,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
701 | { | 725 | { |
702 | if (HasInventoryChanged) | 726 | if (HasInventoryChanged) |
703 | { | 727 | { |
704 | lock (Items) | 728 | Items.LockItemsForRead(true); |
705 | { | 729 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
706 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 730 | Items.LockItemsForRead(false); |
707 | } | ||
708 | 731 | ||
709 | HasInventoryChanged = false; | 732 | HasInventoryChanged = false; |
710 | } | 733 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4e5fee1..4c8c94f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1615,21 +1615,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1615 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | 1615 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); |
1616 | if (part != null) | 1616 | if (part != null) |
1617 | { | 1617 | { |
1618 | part.TaskInventory.LockItemsForRead(true); | ||
1618 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1619 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1619 | if (taskIDict != null) | 1620 | if (taskIDict != null) |
1620 | { | 1621 | { |
1621 | lock (taskIDict) | 1622 | foreach (UUID taskID in taskIDict.Keys) |
1622 | { | 1623 | { |
1623 | foreach (UUID taskID in taskIDict.Keys) | 1624 | UnRegisterControlEventsToScript(LocalId, taskID); |
1624 | { | 1625 | taskIDict[taskID].PermsMask &= ~( |
1625 | UnRegisterControlEventsToScript(LocalId, taskID); | 1626 | 2048 | //PERMISSION_CONTROL_CAMERA |
1626 | taskIDict[taskID].PermsMask &= ~( | 1627 | 4); // PERMISSION_TAKE_CONTROLS |
1627 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1628 | 4); // PERMISSION_TAKE_CONTROLS | ||
1629 | } | ||
1630 | } | 1628 | } |
1631 | |||
1632 | } | 1629 | } |
1630 | part.TaskInventory.LockItemsForRead(false); | ||
1633 | // Reset sit target. | 1631 | // Reset sit target. |
1634 | if (part.GetAvatarOnSitTarget() == UUID) | 1632 | if (part.GetAvatarOnSitTarget() == UUID) |
1635 | part.SetAvatarOnSitTarget(UUID.Zero); | 1633 | part.SetAvatarOnSitTarget(UUID.Zero); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 50b2fb5..a94cd46 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
151 | get { return m_ScriptEngine.World; } | 152 | get { return m_ScriptEngine.World; } |
152 | } | 153 | } |
153 | 154 | ||
155 | [DebuggerNonUserCode] | ||
154 | public void state(string newState) | 156 | public void state(string newState) |
155 | { | 157 | { |
156 | m_ScriptEngine.SetState(m_itemID, newState); | 158 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | /// Reset the named script. The script must be present | 162 | /// Reset the named script. The script must be present |
161 | /// in the same prim. | 163 | /// in the same prim. |
162 | /// </summary> | 164 | /// </summary> |
165 | [DebuggerNonUserCode] | ||
163 | public void llResetScript() | 166 | public void llResetScript() |
164 | { | 167 | { |
165 | m_host.AddScriptLPS(1); | 168 | m_host.AddScriptLPS(1); |
@@ -272,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 275 | protected UUID InventorySelf() |
273 | { | 276 | { |
274 | UUID invItemID = new UUID(); | 277 | UUID invItemID = new UUID(); |
275 | 278 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 279 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
280 | { | ||
281 | m_host.TaskInventory.LockItemsForRead(true); | ||
282 | unlock = true; | ||
283 | } | ||
284 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 285 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 286 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 287 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 288 | invItemID = inv.Key; |
281 | { | 289 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 290 | } |
286 | } | 291 | } |
287 | 292 | if (unlock) | |
293 | { | ||
294 | m_host.TaskInventory.LockItemsForRead(false); | ||
295 | } | ||
288 | return invItemID; | 296 | return invItemID; |
289 | } | 297 | } |
290 | 298 | ||
291 | protected UUID InventoryKey(string name, int type) | 299 | protected UUID InventoryKey(string name, int type) |
292 | { | 300 | { |
293 | m_host.AddScriptLPS(1); | 301 | m_host.AddScriptLPS(1); |
294 | 302 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 303 | |
304 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 305 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 306 | if (inv.Value.Name == name) |
298 | { | 307 | { |
299 | if (inv.Value.Name == name) | 308 | m_host.TaskInventory.LockItemsForRead(false); |
309 | |||
310 | if (inv.Value.Type != type) | ||
300 | { | 311 | { |
301 | if (inv.Value.Type != type) | 312 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 313 | } |
314 | |||
315 | return inv.Value.AssetID; | ||
306 | } | 316 | } |
307 | } | 317 | } |
308 | 318 | ||
319 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 320 | return UUID.Zero; |
310 | } | 321 | } |
311 | 322 | ||
@@ -313,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 324 | { |
314 | m_host.AddScriptLPS(1); | 325 | m_host.AddScriptLPS(1); |
315 | 326 | ||
316 | lock (m_host.TaskInventory) | 327 | |
328 | m_host.TaskInventory.LockItemsForRead(true); | ||
329 | |||
330 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 331 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 332 | if (inv.Value.Name == name) |
319 | { | 333 | { |
320 | if (inv.Value.Name == name) | 334 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 335 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 336 | } |
325 | } | 337 | } |
326 | 338 | ||
339 | m_host.TaskInventory.LockItemsForRead(false); | ||
340 | |||
341 | |||
327 | return UUID.Zero; | 342 | return UUID.Zero; |
328 | } | 343 | } |
329 | 344 | ||
@@ -2534,12 +2549,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2534 | 2549 | ||
2535 | m_host.AddScriptLPS(1); | 2550 | m_host.AddScriptLPS(1); |
2536 | 2551 | ||
2552 | m_host.TaskInventory.LockItemsForRead(true); | ||
2537 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2553 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2538 | 2554 | m_host.TaskInventory.LockItemsForRead(false); | |
2539 | lock (m_host.TaskInventory) | ||
2540 | { | ||
2541 | item = m_host.TaskInventory[invItemID]; | ||
2542 | } | ||
2543 | 2555 | ||
2544 | if (item.PermsGranter == UUID.Zero) | 2556 | if (item.PermsGranter == UUID.Zero) |
2545 | return 0; | 2557 | return 0; |
@@ -2614,6 +2626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2614 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2626 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2615 | return; | 2627 | return; |
2616 | 2628 | ||
2629 | //Clone is thread-safe | ||
2617 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2630 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2618 | 2631 | ||
2619 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2632 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2747,13 +2760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2747 | { | 2760 | { |
2748 | TaskInventoryItem item; | 2761 | TaskInventoryItem item; |
2749 | 2762 | ||
2750 | lock (m_host.TaskInventory) | 2763 | m_host.TaskInventory.LockItemsForRead(true); |
2764 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2751 | { | 2765 | { |
2752 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2766 | m_host.TaskInventory.LockItemsForRead(false); |
2753 | return; | 2767 | return; |
2754 | else | 2768 | } |
2755 | item = m_host.TaskInventory[InventorySelf()]; | 2769 | else |
2770 | { | ||
2771 | item = m_host.TaskInventory[InventorySelf()]; | ||
2756 | } | 2772 | } |
2773 | m_host.TaskInventory.LockItemsForRead(false); | ||
2757 | 2774 | ||
2758 | if (item.PermsGranter != UUID.Zero) | 2775 | if (item.PermsGranter != UUID.Zero) |
2759 | { | 2776 | { |
@@ -2775,13 +2792,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2775 | { | 2792 | { |
2776 | TaskInventoryItem item; | 2793 | TaskInventoryItem item; |
2777 | 2794 | ||
2795 | m_host.TaskInventory.LockItemsForRead(true); | ||
2778 | lock (m_host.TaskInventory) | 2796 | lock (m_host.TaskInventory) |
2779 | { | 2797 | { |
2798 | |||
2780 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2799 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2800 | { | ||
2801 | m_host.TaskInventory.LockItemsForRead(false); | ||
2781 | return; | 2802 | return; |
2803 | } | ||
2782 | else | 2804 | else |
2805 | { | ||
2783 | item = m_host.TaskInventory[InventorySelf()]; | 2806 | item = m_host.TaskInventory[InventorySelf()]; |
2807 | } | ||
2784 | } | 2808 | } |
2809 | m_host.TaskInventory.LockItemsForRead(false); | ||
2785 | 2810 | ||
2786 | m_host.AddScriptLPS(1); | 2811 | m_host.AddScriptLPS(1); |
2787 | 2812 | ||
@@ -2818,14 +2843,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2818 | 2843 | ||
2819 | TaskInventoryItem item; | 2844 | TaskInventoryItem item; |
2820 | 2845 | ||
2821 | lock (m_host.TaskInventory) | 2846 | m_host.TaskInventory.LockItemsForRead(true); |
2847 | |||
2848 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2822 | { | 2849 | { |
2823 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2850 | m_host.TaskInventory.LockItemsForRead(false); |
2824 | return; | 2851 | return; |
2825 | else | 2852 | } |
2826 | item = m_host.TaskInventory[InventorySelf()]; | 2853 | else |
2854 | { | ||
2855 | item = m_host.TaskInventory[InventorySelf()]; | ||
2827 | } | 2856 | } |
2828 | 2857 | ||
2858 | m_host.TaskInventory.LockItemsForRead(false); | ||
2859 | |||
2829 | if (item.PermsGranter != m_host.OwnerID) | 2860 | if (item.PermsGranter != m_host.OwnerID) |
2830 | return; | 2861 | return; |
2831 | 2862 | ||
@@ -2850,13 +2881,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2850 | 2881 | ||
2851 | TaskInventoryItem item; | 2882 | TaskInventoryItem item; |
2852 | 2883 | ||
2853 | lock (m_host.TaskInventory) | 2884 | m_host.TaskInventory.LockItemsForRead(true); |
2885 | |||
2886 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2854 | { | 2887 | { |
2855 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2888 | m_host.TaskInventory.LockItemsForRead(false); |
2856 | return; | 2889 | return; |
2857 | else | 2890 | } |
2858 | item = m_host.TaskInventory[InventorySelf()]; | 2891 | else |
2892 | { | ||
2893 | item = m_host.TaskInventory[InventorySelf()]; | ||
2859 | } | 2894 | } |
2895 | m_host.TaskInventory.LockItemsForRead(false); | ||
2896 | |||
2860 | 2897 | ||
2861 | if (item.PermsGranter != m_host.OwnerID) | 2898 | if (item.PermsGranter != m_host.OwnerID) |
2862 | return; | 2899 | return; |
@@ -3080,14 +3117,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3080 | 3117 | ||
3081 | TaskInventoryItem item; | 3118 | TaskInventoryItem item; |
3082 | 3119 | ||
3083 | lock (m_host.TaskInventory) | 3120 | m_host.TaskInventory.LockItemsForRead(true); |
3121 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3084 | { | 3122 | { |
3085 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3123 | m_host.TaskInventory.LockItemsForRead(false); |
3086 | return; | 3124 | return; |
3087 | else | ||
3088 | item = m_host.TaskInventory[InventorySelf()]; | ||
3089 | } | 3125 | } |
3090 | 3126 | else | |
3127 | { | ||
3128 | item = m_host.TaskInventory[InventorySelf()]; | ||
3129 | } | ||
3130 | m_host.TaskInventory.LockItemsForRead(false); | ||
3091 | if (item.PermsGranter == UUID.Zero) | 3131 | if (item.PermsGranter == UUID.Zero) |
3092 | return; | 3132 | return; |
3093 | 3133 | ||
@@ -3117,13 +3157,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3117 | 3157 | ||
3118 | TaskInventoryItem item; | 3158 | TaskInventoryItem item; |
3119 | 3159 | ||
3120 | lock (m_host.TaskInventory) | 3160 | m_host.TaskInventory.LockItemsForRead(true); |
3161 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3121 | { | 3162 | { |
3122 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3163 | m_host.TaskInventory.LockItemsForRead(false); |
3123 | return; | 3164 | return; |
3124 | else | ||
3125 | item = m_host.TaskInventory[InventorySelf()]; | ||
3126 | } | 3165 | } |
3166 | else | ||
3167 | { | ||
3168 | item = m_host.TaskInventory[InventorySelf()]; | ||
3169 | } | ||
3170 | m_host.TaskInventory.LockItemsForRead(false); | ||
3171 | |||
3127 | 3172 | ||
3128 | if (item.PermsGranter == UUID.Zero) | 3173 | if (item.PermsGranter == UUID.Zero) |
3129 | return; | 3174 | return; |
@@ -3196,10 +3241,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3196 | 3241 | ||
3197 | TaskInventoryItem item; | 3242 | TaskInventoryItem item; |
3198 | 3243 | ||
3199 | lock (m_host.TaskInventory) | 3244 | |
3245 | m_host.TaskInventory.LockItemsForRead(true); | ||
3246 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3247 | { | ||
3248 | m_host.TaskInventory.LockItemsForRead(false); | ||
3249 | return; | ||
3250 | } | ||
3251 | else | ||
3200 | { | 3252 | { |
3201 | item = m_host.TaskInventory[invItemID]; | 3253 | item = m_host.TaskInventory[invItemID]; |
3202 | } | 3254 | } |
3255 | m_host.TaskInventory.LockItemsForRead(false); | ||
3203 | 3256 | ||
3204 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3257 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3205 | { | 3258 | { |
@@ -3231,11 +3284,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3231 | 3284 | ||
3232 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3285 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3233 | { | 3286 | { |
3234 | lock (m_host.TaskInventory) | 3287 | m_host.TaskInventory.LockItemsForWrite(true); |
3235 | { | 3288 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3236 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3289 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3237 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3290 | m_host.TaskInventory.LockItemsForWrite(false); |
3238 | } | ||
3239 | 3291 | ||
3240 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3292 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3241 | "run_time_permissions", new Object[] { | 3293 | "run_time_permissions", new Object[] { |
@@ -3255,11 +3307,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3255 | 3307 | ||
3256 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3308 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3257 | { | 3309 | { |
3258 | lock (m_host.TaskInventory) | 3310 | m_host.TaskInventory.LockItemsForWrite(true); |
3259 | { | 3311 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3260 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3312 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3261 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3313 | m_host.TaskInventory.LockItemsForWrite(false); |
3262 | } | ||
3263 | 3314 | ||
3264 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3315 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3265 | "run_time_permissions", new Object[] { | 3316 | "run_time_permissions", new Object[] { |
@@ -3280,11 +3331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3280 | 3331 | ||
3281 | if (!m_waitingForScriptAnswer) | 3332 | if (!m_waitingForScriptAnswer) |
3282 | { | 3333 | { |
3283 | lock (m_host.TaskInventory) | 3334 | m_host.TaskInventory.LockItemsForWrite(true); |
3284 | { | 3335 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3285 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3336 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3286 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3337 | m_host.TaskInventory.LockItemsForWrite(false); |
3287 | } | ||
3288 | 3338 | ||
3289 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3339 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3290 | m_waitingForScriptAnswer=true; | 3340 | m_waitingForScriptAnswer=true; |
@@ -3319,10 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3319 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3369 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3320 | llReleaseControls(); | 3370 | llReleaseControls(); |
3321 | 3371 | ||
3322 | lock (m_host.TaskInventory) | 3372 | |
3323 | { | 3373 | m_host.TaskInventory.LockItemsForWrite(true); |
3324 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3374 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3325 | } | 3375 | m_host.TaskInventory.LockItemsForWrite(false); |
3376 | |||
3326 | 3377 | ||
3327 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3378 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3328 | "run_time_permissions", new Object[] { | 3379 | "run_time_permissions", new Object[] { |
@@ -3334,16 +3385,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3334 | { | 3385 | { |
3335 | m_host.AddScriptLPS(1); | 3386 | m_host.AddScriptLPS(1); |
3336 | 3387 | ||
3337 | lock (m_host.TaskInventory) | 3388 | m_host.TaskInventory.LockItemsForRead(true); |
3389 | |||
3390 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3338 | { | 3391 | { |
3339 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3392 | if (item.Type == 10 && item.ItemID == m_itemID) |
3340 | { | 3393 | { |
3341 | if (item.Type == 10 && item.ItemID == m_itemID) | 3394 | m_host.TaskInventory.LockItemsForRead(false); |
3342 | { | 3395 | return item.PermsGranter.ToString(); |
3343 | return item.PermsGranter.ToString(); | ||
3344 | } | ||
3345 | } | 3396 | } |
3346 | } | 3397 | } |
3398 | m_host.TaskInventory.LockItemsForRead(false); | ||
3347 | 3399 | ||
3348 | return UUID.Zero.ToString(); | 3400 | return UUID.Zero.ToString(); |
3349 | } | 3401 | } |
@@ -3352,19 +3404,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3352 | { | 3404 | { |
3353 | m_host.AddScriptLPS(1); | 3405 | m_host.AddScriptLPS(1); |
3354 | 3406 | ||
3355 | lock (m_host.TaskInventory) | 3407 | m_host.TaskInventory.LockItemsForRead(true); |
3408 | |||
3409 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3356 | { | 3410 | { |
3357 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3411 | if (item.Type == 10 && item.ItemID == m_itemID) |
3358 | { | 3412 | { |
3359 | if (item.Type == 10 && item.ItemID == m_itemID) | 3413 | int perms = item.PermsMask; |
3360 | { | 3414 | if (m_automaticLinkPermission) |
3361 | int perms = item.PermsMask; | 3415 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3362 | if (m_automaticLinkPermission) | 3416 | m_host.TaskInventory.LockItemsForRead(false); |
3363 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3417 | return perms; |
3364 | return perms; | ||
3365 | } | ||
3366 | } | 3418 | } |
3367 | } | 3419 | } |
3420 | m_host.TaskInventory.LockItemsForRead(false); | ||
3368 | 3421 | ||
3369 | return 0; | 3422 | return 0; |
3370 | } | 3423 | } |
@@ -3397,11 +3450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3397 | UUID invItemID = InventorySelf(); | 3450 | UUID invItemID = InventorySelf(); |
3398 | 3451 | ||
3399 | TaskInventoryItem item; | 3452 | TaskInventoryItem item; |
3400 | lock (m_host.TaskInventory) | 3453 | m_host.TaskInventory.LockItemsForRead(true); |
3401 | { | 3454 | item = m_host.TaskInventory[invItemID]; |
3402 | item = m_host.TaskInventory[invItemID]; | 3455 | m_host.TaskInventory.LockItemsForRead(false); |
3403 | } | 3456 | |
3404 | |||
3405 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3457 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3406 | && !m_automaticLinkPermission) | 3458 | && !m_automaticLinkPermission) |
3407 | { | 3459 | { |
@@ -3454,16 +3506,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3454 | m_host.AddScriptLPS(1); | 3506 | m_host.AddScriptLPS(1); |
3455 | UUID invItemID = InventorySelf(); | 3507 | UUID invItemID = InventorySelf(); |
3456 | 3508 | ||
3457 | lock (m_host.TaskInventory) | 3509 | m_host.TaskInventory.LockItemsForRead(true); |
3458 | { | ||
3459 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3510 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3460 | && !m_automaticLinkPermission) | 3511 | && !m_automaticLinkPermission) |
3461 | { | 3512 | { |
3462 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3513 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3514 | m_host.TaskInventory.LockItemsForRead(false); | ||
3463 | return; | 3515 | return; |
3464 | } | 3516 | } |
3465 | } | 3517 | m_host.TaskInventory.LockItemsForRead(false); |
3466 | 3518 | ||
3467 | if (linknum < ScriptBaseClass.LINK_THIS) | 3519 | if (linknum < ScriptBaseClass.LINK_THIS) |
3468 | return; | 3520 | return; |
3469 | 3521 | ||
@@ -3632,17 +3684,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3632 | m_host.AddScriptLPS(1); | 3684 | m_host.AddScriptLPS(1); |
3633 | int count = 0; | 3685 | int count = 0; |
3634 | 3686 | ||
3635 | lock (m_host.TaskInventory) | 3687 | m_host.TaskInventory.LockItemsForRead(true); |
3688 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3636 | { | 3689 | { |
3637 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3690 | if (inv.Value.Type == type || type == -1) |
3638 | { | 3691 | { |
3639 | if (inv.Value.Type == type || type == -1) | 3692 | count = count + 1; |
3640 | { | ||
3641 | count = count + 1; | ||
3642 | } | ||
3643 | } | 3693 | } |
3644 | } | 3694 | } |
3645 | 3695 | ||
3696 | m_host.TaskInventory.LockItemsForRead(false); | ||
3646 | return count; | 3697 | return count; |
3647 | } | 3698 | } |
3648 | 3699 | ||
@@ -3651,16 +3702,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3651 | m_host.AddScriptLPS(1); | 3702 | m_host.AddScriptLPS(1); |
3652 | ArrayList keys = new ArrayList(); | 3703 | ArrayList keys = new ArrayList(); |
3653 | 3704 | ||
3654 | lock (m_host.TaskInventory) | 3705 | m_host.TaskInventory.LockItemsForRead(true); |
3706 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3655 | { | 3707 | { |
3656 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3708 | if (inv.Value.Type == type || type == -1) |
3657 | { | 3709 | { |
3658 | if (inv.Value.Type == type || type == -1) | 3710 | keys.Add(inv.Value.Name); |
3659 | { | ||
3660 | keys.Add(inv.Value.Name); | ||
3661 | } | ||
3662 | } | 3711 | } |
3663 | } | 3712 | } |
3713 | m_host.TaskInventory.LockItemsForRead(false); | ||
3664 | 3714 | ||
3665 | if (keys.Count == 0) | 3715 | if (keys.Count == 0) |
3666 | { | 3716 | { |
@@ -3697,20 +3747,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3697 | } | 3747 | } |
3698 | 3748 | ||
3699 | // move the first object found with this inventory name | 3749 | // move the first object found with this inventory name |
3700 | lock (m_host.TaskInventory) | 3750 | m_host.TaskInventory.LockItemsForRead(true); |
3751 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3701 | { | 3752 | { |
3702 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3753 | if (inv.Value.Name == inventory) |
3703 | { | 3754 | { |
3704 | if (inv.Value.Name == inventory) | 3755 | found = true; |
3705 | { | 3756 | objId = inv.Key; |
3706 | found = true; | 3757 | assetType = inv.Value.Type; |
3707 | objId = inv.Key; | 3758 | objName = inv.Value.Name; |
3708 | assetType = inv.Value.Type; | 3759 | break; |
3709 | objName = inv.Value.Name; | ||
3710 | break; | ||
3711 | } | ||
3712 | } | 3760 | } |
3713 | } | 3761 | } |
3762 | m_host.TaskInventory.LockItemsForRead(false); | ||
3714 | 3763 | ||
3715 | if (!found) | 3764 | if (!found) |
3716 | { | 3765 | { |
@@ -3755,24 +3804,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3755 | ScriptSleep(3000); | 3804 | ScriptSleep(3000); |
3756 | } | 3805 | } |
3757 | 3806 | ||
3807 | [DebuggerNonUserCode] | ||
3758 | public void llRemoveInventory(string name) | 3808 | public void llRemoveInventory(string name) |
3759 | { | 3809 | { |
3760 | m_host.AddScriptLPS(1); | 3810 | m_host.AddScriptLPS(1); |
3761 | 3811 | ||
3762 | lock (m_host.TaskInventory) | 3812 | m_host.TaskInventory.LockItemsForRead(true); |
3813 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3763 | { | 3814 | { |
3764 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3815 | if (item.Name == name) |
3765 | { | 3816 | { |
3766 | if (item.Name == name) | 3817 | if (item.ItemID == m_itemID) |
3767 | { | 3818 | throw new ScriptDeleteException(); |
3768 | if (item.ItemID == m_itemID) | 3819 | else |
3769 | throw new ScriptDeleteException(); | 3820 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3770 | else | 3821 | |
3771 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3822 | m_host.TaskInventory.LockItemsForRead(false); |
3772 | return; | 3823 | return; |
3773 | } | ||
3774 | } | 3824 | } |
3775 | } | 3825 | } |
3826 | m_host.TaskInventory.LockItemsForRead(false); | ||
3776 | } | 3827 | } |
3777 | 3828 | ||
3778 | public void llSetText(string text, LSL_Vector color, double alpha) | 3829 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3861,6 +3912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3861 | { | 3912 | { |
3862 | m_host.AddScriptLPS(1); | 3913 | m_host.AddScriptLPS(1); |
3863 | 3914 | ||
3915 | //Clone is thread safe | ||
3864 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3916 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3865 | 3917 | ||
3866 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3918 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3951,17 +4003,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3951 | UUID soundId = UUID.Zero; | 4003 | UUID soundId = UUID.Zero; |
3952 | if (!UUID.TryParse(impact_sound, out soundId)) | 4004 | if (!UUID.TryParse(impact_sound, out soundId)) |
3953 | { | 4005 | { |
3954 | lock (m_host.TaskInventory) | 4006 | m_host.TaskInventory.LockItemsForRead(true); |
4007 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3955 | { | 4008 | { |
3956 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4009 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3957 | { | 4010 | { |
3958 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4011 | soundId = item.AssetID; |
3959 | { | 4012 | break; |
3960 | soundId = item.AssetID; | ||
3961 | break; | ||
3962 | } | ||
3963 | } | 4013 | } |
3964 | } | 4014 | } |
4015 | m_host.TaskInventory.LockItemsForRead(false); | ||
3965 | } | 4016 | } |
3966 | m_host.CollisionSound = soundId; | 4017 | m_host.CollisionSound = soundId; |
3967 | m_host.CollisionSoundVolume = (float)impact_volume; | 4018 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4007,6 +4058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4007 | UUID partItemID; | 4058 | UUID partItemID; |
4008 | foreach (SceneObjectPart part in parts) | 4059 | foreach (SceneObjectPart part in parts) |
4009 | { | 4060 | { |
4061 | //Clone is thread safe | ||
4010 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4062 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4011 | 4063 | ||
4012 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4064 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4214,17 +4266,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4214 | 4266 | ||
4215 | m_host.AddScriptLPS(1); | 4267 | m_host.AddScriptLPS(1); |
4216 | 4268 | ||
4217 | lock (m_host.TaskInventory) | 4269 | m_host.TaskInventory.LockItemsForRead(true); |
4270 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4218 | { | 4271 | { |
4219 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4272 | if (item.Type == 10 && item.ItemID == m_itemID) |
4220 | { | 4273 | { |
4221 | if (item.Type == 10 && item.ItemID == m_itemID) | 4274 | result = item.Name!=null?item.Name:String.Empty; |
4222 | { | 4275 | break; |
4223 | result = item.Name!=null?item.Name:String.Empty; | ||
4224 | break; | ||
4225 | } | ||
4226 | } | 4276 | } |
4227 | } | 4277 | } |
4278 | m_host.TaskInventory.LockItemsForRead(false); | ||
4228 | 4279 | ||
4229 | return result; | 4280 | return result; |
4230 | } | 4281 | } |
@@ -4482,23 +4533,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4482 | { | 4533 | { |
4483 | m_host.AddScriptLPS(1); | 4534 | m_host.AddScriptLPS(1); |
4484 | 4535 | ||
4485 | lock (m_host.TaskInventory) | 4536 | m_host.TaskInventory.LockItemsForRead(true); |
4537 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4486 | { | 4538 | { |
4487 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4539 | if (inv.Value.Name == name) |
4488 | { | 4540 | { |
4489 | if (inv.Value.Name == name) | 4541 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4490 | { | 4542 | { |
4491 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4543 | m_host.TaskInventory.LockItemsForRead(false); |
4492 | { | 4544 | return inv.Value.AssetID.ToString(); |
4493 | return inv.Value.AssetID.ToString(); | 4545 | } |
4494 | } | 4546 | else |
4495 | else | 4547 | { |
4496 | { | 4548 | m_host.TaskInventory.LockItemsForRead(false); |
4497 | return UUID.Zero.ToString(); | 4549 | return UUID.Zero.ToString(); |
4498 | } | ||
4499 | } | 4550 | } |
4500 | } | 4551 | } |
4501 | } | 4552 | } |
4553 | m_host.TaskInventory.LockItemsForRead(false); | ||
4502 | 4554 | ||
4503 | return UUID.Zero.ToString(); | 4555 | return UUID.Zero.ToString(); |
4504 | } | 4556 | } |
@@ -5993,14 +6045,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5993 | 6045 | ||
5994 | protected UUID GetTaskInventoryItem(string name) | 6046 | protected UUID GetTaskInventoryItem(string name) |
5995 | { | 6047 | { |
5996 | lock (m_host.TaskInventory) | 6048 | m_host.TaskInventory.LockItemsForRead(true); |
6049 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
5997 | { | 6050 | { |
5998 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6051 | if (inv.Value.Name == name) |
5999 | { | 6052 | { |
6000 | if (inv.Value.Name == name) | 6053 | m_host.TaskInventory.LockItemsForRead(false); |
6001 | return inv.Key; | 6054 | return inv.Key; |
6002 | } | 6055 | } |
6003 | } | 6056 | } |
6057 | m_host.TaskInventory.LockItemsForRead(false); | ||
6004 | 6058 | ||
6005 | return UUID.Zero; | 6059 | return UUID.Zero; |
6006 | } | 6060 | } |
@@ -6311,22 +6365,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6311 | } | 6365 | } |
6312 | 6366 | ||
6313 | // copy the first script found with this inventory name | 6367 | // copy the first script found with this inventory name |
6314 | lock (m_host.TaskInventory) | 6368 | m_host.TaskInventory.LockItemsForRead(true); |
6369 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6315 | { | 6370 | { |
6316 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6371 | if (inv.Value.Name == name) |
6317 | { | 6372 | { |
6318 | if (inv.Value.Name == name) | 6373 | // make sure the object is a script |
6374 | if (10 == inv.Value.Type) | ||
6319 | { | 6375 | { |
6320 | // make sure the object is a script | 6376 | found = true; |
6321 | if (10 == inv.Value.Type) | 6377 | srcId = inv.Key; |
6322 | { | 6378 | break; |
6323 | found = true; | ||
6324 | srcId = inv.Key; | ||
6325 | break; | ||
6326 | } | ||
6327 | } | 6379 | } |
6328 | } | 6380 | } |
6329 | } | 6381 | } |
6382 | m_host.TaskInventory.LockItemsForRead(false); | ||
6330 | 6383 | ||
6331 | if (!found) | 6384 | if (!found) |
6332 | { | 6385 | { |
@@ -8129,28 +8182,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8129 | { | 8182 | { |
8130 | m_host.AddScriptLPS(1); | 8183 | m_host.AddScriptLPS(1); |
8131 | 8184 | ||
8132 | lock (m_host.TaskInventory) | 8185 | m_host.TaskInventory.LockItemsForRead(true); |
8186 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8133 | { | 8187 | { |
8134 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8188 | if (inv.Value.Name == item) |
8135 | { | 8189 | { |
8136 | if (inv.Value.Name == item) | 8190 | m_host.TaskInventory.LockItemsForRead(false); |
8191 | switch (mask) | ||
8137 | { | 8192 | { |
8138 | switch (mask) | 8193 | case 0: |
8139 | { | 8194 | return (int)inv.Value.BasePermissions; |
8140 | case 0: | 8195 | case 1: |
8141 | return (int)inv.Value.BasePermissions; | 8196 | return (int)inv.Value.CurrentPermissions; |
8142 | case 1: | 8197 | case 2: |
8143 | return (int)inv.Value.CurrentPermissions; | 8198 | return (int)inv.Value.GroupPermissions; |
8144 | case 2: | 8199 | case 3: |
8145 | return (int)inv.Value.GroupPermissions; | 8200 | return (int)inv.Value.EveryonePermissions; |
8146 | case 3: | 8201 | case 4: |
8147 | return (int)inv.Value.EveryonePermissions; | 8202 | return (int)inv.Value.NextPermissions; |
8148 | case 4: | ||
8149 | return (int)inv.Value.NextPermissions; | ||
8150 | } | ||
8151 | } | 8203 | } |
8152 | } | 8204 | } |
8153 | } | 8205 | } |
8206 | m_host.TaskInventory.LockItemsForRead(false); | ||
8154 | 8207 | ||
8155 | return -1; | 8208 | return -1; |
8156 | } | 8209 | } |
@@ -8165,16 +8218,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8165 | { | 8218 | { |
8166 | m_host.AddScriptLPS(1); | 8219 | m_host.AddScriptLPS(1); |
8167 | 8220 | ||
8168 | lock (m_host.TaskInventory) | 8221 | m_host.TaskInventory.LockItemsForRead(true); |
8222 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8169 | { | 8223 | { |
8170 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8224 | if (inv.Value.Name == item) |
8171 | { | 8225 | { |
8172 | if (inv.Value.Name == item) | 8226 | m_host.TaskInventory.LockItemsForRead(false); |
8173 | { | 8227 | return inv.Value.CreatorID.ToString(); |
8174 | return inv.Value.CreatorID.ToString(); | ||
8175 | } | ||
8176 | } | 8228 | } |
8177 | } | 8229 | } |
8230 | m_host.TaskInventory.LockItemsForRead(false); | ||
8178 | 8231 | ||
8179 | llSay(0, "No item name '" + item + "'"); | 8232 | llSay(0, "No item name '" + item + "'"); |
8180 | 8233 | ||
@@ -8698,16 +8751,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8698 | { | 8751 | { |
8699 | m_host.AddScriptLPS(1); | 8752 | m_host.AddScriptLPS(1); |
8700 | 8753 | ||
8701 | lock (m_host.TaskInventory) | 8754 | m_host.TaskInventory.LockItemsForRead(true); |
8755 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8702 | { | 8756 | { |
8703 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8757 | if (inv.Value.Name == name) |
8704 | { | 8758 | { |
8705 | if (inv.Value.Name == name) | 8759 | m_host.TaskInventory.LockItemsForRead(false); |
8706 | { | 8760 | return inv.Value.Type; |
8707 | return inv.Value.Type; | ||
8708 | } | ||
8709 | } | 8761 | } |
8710 | } | 8762 | } |
8763 | m_host.TaskInventory.LockItemsForRead(false); | ||
8711 | 8764 | ||
8712 | return -1; | 8765 | return -1; |
8713 | } | 8766 | } |
@@ -8738,17 +8791,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8738 | if (invItemID == UUID.Zero) | 8791 | if (invItemID == UUID.Zero) |
8739 | return new LSL_Vector(); | 8792 | return new LSL_Vector(); |
8740 | 8793 | ||
8741 | lock (m_host.TaskInventory) | 8794 | m_host.TaskInventory.LockItemsForRead(true); |
8795 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8742 | { | 8796 | { |
8743 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8797 | m_host.TaskInventory.LockItemsForRead(false); |
8744 | return new LSL_Vector(); | 8798 | return new LSL_Vector(); |
8799 | } | ||
8745 | 8800 | ||
8746 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8801 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8747 | { | 8802 | { |
8748 | ShoutError("No permissions to track the camera"); | 8803 | ShoutError("No permissions to track the camera"); |
8749 | return new LSL_Vector(); | 8804 | m_host.TaskInventory.LockItemsForRead(false); |
8750 | } | 8805 | return new LSL_Vector(); |
8751 | } | 8806 | } |
8807 | m_host.TaskInventory.LockItemsForRead(false); | ||
8752 | 8808 | ||
8753 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8809 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8754 | if (presence != null) | 8810 | if (presence != null) |
@@ -8766,17 +8822,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8766 | if (invItemID == UUID.Zero) | 8822 | if (invItemID == UUID.Zero) |
8767 | return new LSL_Rotation(); | 8823 | return new LSL_Rotation(); |
8768 | 8824 | ||
8769 | lock (m_host.TaskInventory) | 8825 | m_host.TaskInventory.LockItemsForRead(true); |
8826 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8770 | { | 8827 | { |
8771 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8828 | m_host.TaskInventory.LockItemsForRead(false); |
8772 | return new LSL_Rotation(); | 8829 | return new LSL_Rotation(); |
8773 | |||
8774 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8775 | { | ||
8776 | ShoutError("No permissions to track the camera"); | ||
8777 | return new LSL_Rotation(); | ||
8778 | } | ||
8779 | } | 8830 | } |
8831 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8832 | { | ||
8833 | ShoutError("No permissions to track the camera"); | ||
8834 | m_host.TaskInventory.LockItemsForRead(false); | ||
8835 | return new LSL_Rotation(); | ||
8836 | } | ||
8837 | m_host.TaskInventory.LockItemsForRead(false); | ||
8780 | 8838 | ||
8781 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8839 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8782 | if (presence != null) | 8840 | if (presence != null) |
@@ -8926,14 +8984,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8926 | if (objectID == UUID.Zero) return; | 8984 | if (objectID == UUID.Zero) return; |
8927 | 8985 | ||
8928 | UUID agentID; | 8986 | UUID agentID; |
8929 | lock (m_host.TaskInventory) | 8987 | m_host.TaskInventory.LockItemsForRead(true); |
8930 | { | 8988 | // we need the permission first, to know which avatar we want to set the camera for |
8931 | // we need the permission first, to know which avatar we want to set the camera for | 8989 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8932 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8933 | 8990 | ||
8934 | if (agentID == UUID.Zero) return; | 8991 | if (agentID == UUID.Zero) |
8935 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 8992 | { |
8993 | m_host.TaskInventory.LockItemsForRead(false); | ||
8994 | return; | ||
8995 | } | ||
8996 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
8997 | { | ||
8998 | m_host.TaskInventory.LockItemsForRead(false); | ||
8999 | return; | ||
8936 | } | 9000 | } |
9001 | m_host.TaskInventory.LockItemsForRead(false); | ||
8937 | 9002 | ||
8938 | ScenePresence presence = World.GetScenePresence(agentID); | 9003 | ScenePresence presence = World.GetScenePresence(agentID); |
8939 | 9004 | ||
@@ -8983,12 +9048,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8983 | 9048 | ||
8984 | // we need the permission first, to know which avatar we want to clear the camera for | 9049 | // we need the permission first, to know which avatar we want to clear the camera for |
8985 | UUID agentID; | 9050 | UUID agentID; |
8986 | lock (m_host.TaskInventory) | 9051 | m_host.TaskInventory.LockItemsForRead(true); |
9052 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9053 | if (agentID == UUID.Zero) | ||
8987 | { | 9054 | { |
8988 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9055 | m_host.TaskInventory.LockItemsForRead(false); |
8989 | if (agentID == UUID.Zero) return; | 9056 | return; |
8990 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
8991 | } | 9057 | } |
9058 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9059 | { | ||
9060 | m_host.TaskInventory.LockItemsForRead(false); | ||
9061 | return; | ||
9062 | } | ||
9063 | m_host.TaskInventory.LockItemsForRead(false); | ||
8992 | 9064 | ||
8993 | ScenePresence presence = World.GetScenePresence(agentID); | 9065 | ScenePresence presence = World.GetScenePresence(agentID); |
8994 | 9066 | ||
@@ -9445,15 +9517,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9445 | 9517 | ||
9446 | internal UUID ScriptByName(string name) | 9518 | internal UUID ScriptByName(string name) |
9447 | { | 9519 | { |
9448 | lock (m_host.TaskInventory) | 9520 | m_host.TaskInventory.LockItemsForRead(true); |
9521 | |||
9522 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9449 | { | 9523 | { |
9450 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9524 | if (item.Type == 10 && item.Name == name) |
9451 | { | 9525 | { |
9452 | if (item.Type == 10 && item.Name == name) | 9526 | m_host.TaskInventory.LockItemsForRead(false); |
9453 | return item.ItemID; | 9527 | return item.ItemID; |
9454 | } | 9528 | } |
9455 | } | 9529 | } |
9456 | 9530 | ||
9531 | m_host.TaskInventory.LockItemsForRead(false); | ||
9532 | |||
9457 | return UUID.Zero; | 9533 | return UUID.Zero; |
9458 | } | 9534 | } |
9459 | 9535 | ||
@@ -9494,6 +9570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9494 | { | 9570 | { |
9495 | m_host.AddScriptLPS(1); | 9571 | m_host.AddScriptLPS(1); |
9496 | 9572 | ||
9573 | //Clone is thread safe | ||
9497 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9574 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9498 | 9575 | ||
9499 | UUID assetID = UUID.Zero; | 9576 | UUID assetID = UUID.Zero; |
@@ -9556,6 +9633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9556 | { | 9633 | { |
9557 | m_host.AddScriptLPS(1); | 9634 | m_host.AddScriptLPS(1); |
9558 | 9635 | ||
9636 | //Clone is thread safe | ||
9559 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9637 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9560 | 9638 | ||
9561 | UUID assetID = UUID.Zero; | 9639 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7fdbac8..83322eb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | if (target != null) | 728 | if (target != null) |
729 | { | 729 | { |
730 | UUID animID=UUID.Zero; | 730 | UUID animID=UUID.Zero; |
731 | lock (m_host.TaskInventory) | 731 | m_host.TaskInventory.LockItemsForRead(true); |
732 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
732 | { | 733 | { |
733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 734 | if (inv.Value.Name == animation) |
734 | { | 735 | { |
735 | if (inv.Value.Name == animation) | 736 | if (inv.Value.Type == (int)AssetType.Animation) |
736 | { | 737 | animID = inv.Value.AssetID; |
737 | if (inv.Value.Type == (int)AssetType.Animation) | 738 | continue; |
738 | animID = inv.Value.AssetID; | ||
739 | continue; | ||
740 | } | ||
741 | } | 739 | } |
742 | } | 740 | } |
741 | m_host.TaskInventory.LockItemsForRead(false); | ||
743 | if (animID == UUID.Zero) | 742 | if (animID == UUID.Zero) |
744 | target.Animator.AddAnimation(animation, m_host.UUID); | 743 | target.Animator.AddAnimation(animation, m_host.UUID); |
745 | else | 744 | else |
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
761 | if (target != null) | 760 | if (target != null) |
762 | { | 761 | { |
763 | UUID animID=UUID.Zero; | 762 | UUID animID=UUID.Zero; |
764 | lock (m_host.TaskInventory) | 763 | m_host.TaskInventory.LockItemsForRead(true); |
764 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
765 | { | 765 | { |
766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 766 | if (inv.Value.Name == animation) |
767 | { | 767 | { |
768 | if (inv.Value.Name == animation) | 768 | if (inv.Value.Type == (int)AssetType.Animation) |
769 | { | 769 | animID = inv.Value.AssetID; |
770 | if (inv.Value.Type == (int)AssetType.Animation) | 770 | continue; |
771 | animID = inv.Value.AssetID; | ||
772 | continue; | ||
773 | } | ||
774 | } | 771 | } |
775 | } | 772 | } |
773 | m_host.TaskInventory.LockItemsForRead(false); | ||
776 | 774 | ||
777 | if (animID == UUID.Zero) | 775 | if (animID == UUID.Zero) |
778 | target.Animator.RemoveAnimation(animation); | 776 | target.Animator.RemoveAnimation(animation); |
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1541 | 1539 | ||
1542 | if (!UUID.TryParse(name, out assetID)) | 1540 | if (!UUID.TryParse(name, out assetID)) |
1543 | { | 1541 | { |
1542 | m_host.TaskInventory.LockItemsForRead(true); | ||
1544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1543 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1545 | { | 1544 | { |
1546 | if (item.Type == 7 && item.Name == name) | 1545 | if (item.Type == 7 && item.Name == name) |
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1548 | assetID = item.AssetID; | 1547 | assetID = item.AssetID; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1550 | m_host.TaskInventory.LockItemsForRead(false); | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if (assetID == UUID.Zero) | 1553 | if (assetID == UUID.Zero) |
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1594 | 1594 | ||
1595 | if (!UUID.TryParse(name, out assetID)) | 1595 | if (!UUID.TryParse(name, out assetID)) |
1596 | { | 1596 | { |
1597 | m_host.TaskInventory.LockItemsForRead(true); | ||
1597 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1598 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1598 | { | 1599 | { |
1599 | if (item.Type == 7 && item.Name == name) | 1600 | if (item.Type == 7 && item.Name == name) |
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1601 | assetID = item.AssetID; | 1602 | assetID = item.AssetID; |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1605 | m_host.TaskInventory.LockItemsForRead(false); | ||
1604 | } | 1606 | } |
1605 | 1607 | ||
1606 | if (assetID == UUID.Zero) | 1608 | if (assetID == UUID.Zero) |
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1651 | 1653 | ||
1652 | if (!UUID.TryParse(name, out assetID)) | 1654 | if (!UUID.TryParse(name, out assetID)) |
1653 | { | 1655 | { |
1656 | m_host.TaskInventory.LockItemsForRead(true); | ||
1654 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1657 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1655 | { | 1658 | { |
1656 | if (item.Type == 7 && item.Name == name) | 1659 | if (item.Type == 7 && item.Name == name) |
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1658 | assetID = item.AssetID; | 1661 | assetID = item.AssetID; |
1659 | } | 1662 | } |
1660 | } | 1663 | } |
1664 | m_host.TaskInventory.LockItemsForRead(false); | ||
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | if (assetID == UUID.Zero) | 1667 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 7f67599..15e0408 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
131 | return (eventFlags); | 132 | return (eventFlags); |
132 | } | 133 | } |
133 | 134 | ||
135 | [DebuggerNonUserCode] | ||
134 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 136 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
135 | { | 137 | { |
136 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 138 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 121159c..a44abb0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d49..0f4a9ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -237,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
237 | 238 | ||
238 | if (part != null) | 239 | if (part != null) |
239 | { | 240 | { |
240 | lock (part.TaskInventory) | 241 | part.TaskInventory.LockItemsForRead(true); |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
241 | { | 243 | { |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
243 | { | ||
244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
245 | } | ||
246 | } | 245 | } |
246 | part.TaskInventory.LockItemsForRead(false); | ||
247 | } | 247 | } |
248 | 248 | ||
249 | ApiManager am = new ApiManager(); | 249 | ApiManager am = new ApiManager(); |
@@ -428,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
428 | { | 428 | { |
429 | int permsMask; | 429 | int permsMask; |
430 | UUID permsGranter; | 430 | UUID permsGranter; |
431 | lock (part.TaskInventory) | 431 | part.TaskInventory.LockItemsForRead(true); |
432 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
432 | { | 433 | { |
433 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 434 | part.TaskInventory.LockItemsForRead(false); |
434 | return; | 435 | return; |
435 | |||
436 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
437 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
438 | } | 436 | } |
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | part.TaskInventory.LockItemsForRead(false); | ||
439 | 440 | ||
440 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
441 | { | 442 | { |
@@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
544 | return true; | 545 | return true; |
545 | } | 546 | } |
546 | 547 | ||
548 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
547 | public void SetState(string state) | 549 | public void SetState(string state) |
548 | { | 550 | { |
549 | if (state == State) | 551 | if (state == State) |
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
555 | new DetectParams[0])); | 557 | new DetectParams[0])); |
556 | PostEvent(new EventParams("state_entry", new Object[0], | 558 | PostEvent(new EventParams("state_entry", new Object[0], |
557 | new DetectParams[0])); | 559 | new DetectParams[0])); |
558 | 560 | ||
559 | throw new EventAbortException(); | 561 | throw new EventAbortException(); |
560 | } | 562 | } |
561 | 563 | ||
@@ -638,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
638 | /// <returns></returns> | 640 | /// <returns></returns> |
639 | public object EventProcessor() | 641 | public object EventProcessor() |
640 | { | 642 | { |
643 | |||
644 | EventParams data = null; | ||
645 | |||
646 | lock (m_EventQueue) | ||
647 | { | ||
641 | lock (m_Script) | 648 | lock (m_Script) |
642 | { | 649 | { |
643 | EventParams data = null; | 650 | data = (EventParams) m_EventQueue.Dequeue(); |
644 | 651 | if (data == null) // Shouldn't happen | |
645 | lock (m_EventQueue) | ||
646 | { | 652 | { |
647 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) |
648 | if (data == null) // Shouldn't happen | ||
649 | { | 654 | { |
650 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 655 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
651 | { | ||
652 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | m_CurrentResult = null; | ||
657 | } | ||
658 | return 0; | ||
659 | } | 656 | } |
660 | 657 | else | |
661 | if (data.EventName == "timer") | ||
662 | m_TimerQueued = false; | ||
663 | if (data.EventName == "control") | ||
664 | { | 658 | { |
665 | if (m_ControlEventsInQueue > 0) | 659 | m_CurrentResult = null; |
666 | m_ControlEventsInQueue--; | ||
667 | } | 660 | } |
668 | if (data.EventName == "collision") | 661 | return 0; |
669 | m_CollisionInQueue = false; | ||
670 | } | 662 | } |
671 | |||
672 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
673 | 663 | ||
674 | m_DetectParams = data.DetectParams; | 664 | if (data.EventName == "timer") |
675 | 665 | m_TimerQueued = false; | |
676 | if (data.EventName == "state") // Hardcoded state change | 666 | if (data.EventName == "control") |
677 | { | 667 | { |
678 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 668 | if (m_ControlEventsInQueue > 0) |
679 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 669 | m_ControlEventsInQueue--; |
680 | m_State=data.Params[0].ToString(); | 670 | } |
681 | AsyncCommandManager.RemoveScript(m_Engine, | 671 | if (data.EventName == "collision") |
682 | m_LocalID, m_ItemID); | 672 | m_CollisionInQueue = false; |
673 | } | ||
674 | } | ||
675 | lock(m_Script) | ||
676 | { | ||
677 | |||
678 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
683 | 679 | ||
684 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 680 | m_DetectParams = data.DetectParams; |
685 | m_LocalID); | 681 | |
686 | if (part != null) | 682 | if (data.EventName == "state") // Hardcoded state change |
687 | { | 683 | { |
688 | part.SetScriptEvents(m_ItemID, | 684 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
689 | (int)m_Script.GetStateEventFlags(State)); | 685 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); |
690 | } | 686 | m_State=data.Params[0].ToString(); |
687 | AsyncCommandManager.RemoveScript(m_Engine, | ||
688 | m_LocalID, m_ItemID); | ||
689 | |||
690 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | ||
691 | m_LocalID); | ||
692 | if (part != null) | ||
693 | { | ||
694 | part.SetScriptEvents(m_ItemID, | ||
695 | (int)m_Script.GetStateEventFlags(State)); | ||
691 | } | 696 | } |
692 | else | 697 | } |
698 | else | ||
699 | { | ||
700 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | ||
701 | data.EventName == "control") // Don't freeze avies! | ||
693 | { | 702 | { |
694 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 703 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
695 | data.EventName == "control") // Don't freeze avies! | 704 | m_LocalID); |
696 | { | 705 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
697 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 706 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
698 | m_LocalID); | ||
699 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | ||
700 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
701 | 707 | ||
702 | try | 708 | try |
703 | { | 709 | { |
704 | m_CurrentEvent = data.EventName; | 710 | m_CurrentEvent = data.EventName; |
705 | m_EventStart = DateTime.Now; | 711 | m_EventStart = DateTime.Now; |
706 | m_InEvent = true; | 712 | m_InEvent = true; |
707 | 713 | ||
708 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 714 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
709 | 715 | ||
710 | m_InEvent = false; | 716 | m_InEvent = false; |
711 | m_CurrentEvent = String.Empty; | 717 | m_CurrentEvent = String.Empty; |
712 | 718 | ||
713 | if (m_SaveState) | 719 | if (m_SaveState) |
714 | { | 720 | { |
715 | // This will be the very first event we deliver | 721 | // This will be the very first event we deliver |
716 | // (state_entry) in default state | 722 | // (state_entry) in default state |
717 | // | 723 | // |
718 | 724 | ||
719 | SaveState(m_Assembly); | 725 | SaveState(m_Assembly); |
720 | 726 | ||
721 | m_SaveState = false; | 727 | m_SaveState = false; |
722 | } | ||
723 | } | 728 | } |
724 | catch (Exception e) | 729 | } |
725 | { | 730 | catch (Exception e) |
726 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); | 731 | { |
727 | m_InEvent = false; | 732 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); |
728 | m_CurrentEvent = String.Empty; | 733 | m_InEvent = false; |
734 | m_CurrentEvent = String.Empty; | ||
729 | 735 | ||
730 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) | 736 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) |
731 | { | 737 | { |
732 | try | 738 | try |
733 | { | ||
734 | // DISPLAY ERROR INWORLD | ||
735 | string text = FormatException(e); | ||
736 | |||
737 | if (text.Length > 1000) | ||
738 | text = text.Substring(0, 1000); | ||
739 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
740 | ChatTypeEnum.DebugChannel, 2147483647, | ||
741 | part.AbsolutePosition, | ||
742 | part.Name, part.UUID, false); | ||
743 | } | ||
744 | catch (Exception) | ||
745 | { | ||
746 | } | ||
747 | // catch (Exception e2) // LEGIT: User Scripting | ||
748 | // { | ||
749 | // m_log.Error("[SCRIPT]: "+ | ||
750 | // "Error displaying error in-world: " + | ||
751 | // e2.ToString()); | ||
752 | // m_log.Error("[SCRIPT]: " + | ||
753 | // "Errormessage: Error compiling script:\r\n" + | ||
754 | // e.ToString()); | ||
755 | // } | ||
756 | } | ||
757 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
758 | { | 739 | { |
759 | m_InSelfDelete = true; | 740 | // DISPLAY ERROR INWORLD |
760 | if (part != null && part.ParentGroup != null) | 741 | string text = FormatException(e); |
761 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 742 | |
743 | if (text.Length > 1000) | ||
744 | text = text.Substring(0, 1000); | ||
745 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
746 | ChatTypeEnum.DebugChannel, 2147483647, | ||
747 | part.AbsolutePosition, | ||
748 | part.Name, part.UUID, false); | ||
762 | } | 749 | } |
763 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 750 | catch (Exception) |
764 | { | 751 | { |
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
768 | } | 752 | } |
753 | // catch (Exception e2) // LEGIT: User Scripting | ||
754 | // { | ||
755 | // m_log.Error("[SCRIPT]: "+ | ||
756 | // "Error displaying error in-world: " + | ||
757 | // e2.ToString()); | ||
758 | // m_log.Error("[SCRIPT]: " + | ||
759 | // "Errormessage: Error compiling script:\r\n" + | ||
760 | // e.ToString()); | ||
761 | // } | ||
762 | } | ||
763 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
764 | { | ||
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
768 | } | ||
769 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | ||
770 | { | ||
771 | m_InSelfDelete = true; | ||
772 | if (part != null && part.ParentGroup != null) | ||
773 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
769 | } | 774 | } |
770 | } | 775 | } |
771 | } | 776 | } |
777 | } | ||
772 | 778 | ||
773 | lock (m_EventQueue) | 779 | lock (m_EventQueue) |
780 | { | ||
781 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | ||
774 | { | 782 | { |
775 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 783 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
776 | { | 784 | } |
777 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 785 | else |
778 | } | 786 | { |
779 | else | 787 | m_CurrentResult = null; |
780 | { | ||
781 | m_CurrentResult = null; | ||
782 | } | ||
783 | } | 788 | } |
789 | } | ||
784 | 790 | ||
785 | m_DetectParams = null; | 791 | m_DetectParams = null; |
786 | 792 | ||
787 | return 0; | 793 | return 0; |
788 | } | 794 | } |
789 | } | 795 | } |
790 | 796 | ||
791 | public int EventTime() | 797 | public int EventTime() |
@@ -824,6 +830,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
824 | new Object[0], new DetectParams[0])); | 830 | new Object[0], new DetectParams[0])); |
825 | } | 831 | } |
826 | 832 | ||
833 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
827 | public void ApiResetScript() | 834 | public void ApiResetScript() |
828 | { | 835 | { |
829 | // bool running = Running; | 836 | // bool running = Running; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a60c0ba..8b94f28 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Reflection; |
@@ -1119,6 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1119 | return false; | 1120 | return false; |
1120 | } | 1121 | } |
1121 | 1122 | ||
1123 | [DebuggerNonUserCode] | ||
1122 | public void ApiResetScript(UUID itemID) | 1124 | public void ApiResetScript(UUID itemID) |
1123 | { | 1125 | { |
1124 | IScriptInstance instance = GetInstance(itemID); | 1126 | IScriptInstance instance = GetInstance(itemID); |
@@ -1170,6 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1170 | return UUID.Zero; | 1172 | return UUID.Zero; |
1171 | } | 1173 | } |
1172 | 1174 | ||
1175 | [DebuggerNonUserCode] | ||
1173 | public void SetState(UUID itemID, string newState) | 1176 | public void SetState(UUID itemID, string newState) |
1174 | { | 1177 | { |
1175 | IScriptInstance instance = GetInstance(itemID); | 1178 | IScriptInstance instance = GetInstance(itemID); |