diff options
author | Justin Clarke Casey | 2009-02-20 14:04:29 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-20 14:04:29 +0000 |
commit | 01f70de2ea562f78991084be01a83295f8f2be0b (patch) | |
tree | ff43706bf83039ce9d9c6c5bfffe56f2df1d1c86 /OpenSim/Region/ScriptEngine/Shared/Instance | |
parent | Revert previous commit (diff) | |
download | opensim-SC-01f70de2ea562f78991084be01a83295f8f2be0b.zip opensim-SC-01f70de2ea562f78991084be01a83295f8f2be0b.tar.gz opensim-SC-01f70de2ea562f78991084be01a83295f8f2be0b.tar.bz2 opensim-SC-01f70de2ea562f78991084be01a83295f8f2be0b.tar.xz |
* Consistently lock part.TaskInventory as pointed out in http://opensimulator.org/mantis/view.php?id=3159
* Not locking causes enumeration exceptions as described in this matis
* part.TaskInventory needs to be locked for every access as it's a dictionary
* Extra locking will hopefully not cause any major issues - in places where the enumeration of the dictionary performs other lock or long running operations, the dictionary is
cloned instead
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 96c1698..20e70d0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -231,9 +231,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
231 | m_stateSource = stateSource; | 231 | m_stateSource = stateSource; |
232 | m_postOnRez = postOnRez; | 232 | m_postOnRez = postOnRez; |
233 | 233 | ||
234 | if (part != null && part.TaskInventory.ContainsKey(m_ItemID)) | 234 | if (part != null) |
235 | { | 235 | { |
236 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | 236 | lock (part.TaskInventory) |
237 | { | ||
238 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
239 | { | ||
240 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
241 | } | ||
242 | } | ||
237 | } | 243 | } |
238 | 244 | ||
239 | ApiManager am = new ApiManager(); | 245 | ApiManager am = new ApiManager(); |
@@ -399,15 +405,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
399 | 405 | ||
400 | private void ReleaseControls() | 406 | private void ReleaseControls() |
401 | { | 407 | { |
402 | SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); | 408 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart(m_LocalID); |
403 | if (part != null && part.TaskInventory.ContainsKey(m_ItemID)) | 409 | |
410 | if (part != null) | ||
404 | { | 411 | { |
405 | UUID permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | 412 | int permsMask; |
406 | int permsMask = part.TaskInventory[m_ItemID].PermsMask; | 413 | UUID permsGranter; |
414 | lock (part.TaskInventory) | ||
415 | { | ||
416 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
417 | return; | ||
418 | |||
419 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
420 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
421 | } | ||
407 | 422 | ||
408 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 423 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
409 | { | 424 | { |
410 | |||
411 | ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter); | 425 | ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter); |
412 | if (presence != null) | 426 | if (presence != null) |
413 | presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); | 427 | presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); |