* 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
This commit is contained in:
Justin Clarke Casey
2009-02-20 14:04:29 +00:00
parent c28b2f799a
commit 01f70de2ea
7 changed files with 417 additions and 204 deletions

View File

@@ -231,9 +231,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_stateSource = stateSource;
m_postOnRez = postOnRez;
if (part != null && part.TaskInventory.ContainsKey(m_ItemID))
if (part != null)
{
m_thisScriptTask = part.TaskInventory[m_ItemID];
lock (part.TaskInventory)
{
if (part.TaskInventory.ContainsKey(m_ItemID))
{
m_thisScriptTask = part.TaskInventory[m_ItemID];
}
}
}
ApiManager am = new ApiManager();
@@ -399,15 +405,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private void ReleaseControls()
{
SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
if (part != null && part.TaskInventory.ContainsKey(m_ItemID))
SceneObjectPart part = m_Engine.World.GetSceneObjectPart(m_LocalID);
if (part != null)
{
UUID permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
int permsMask = part.TaskInventory[m_ItemID].PermsMask;
int permsMask;
UUID permsGranter;
lock (part.TaskInventory)
{
if (!part.TaskInventory.ContainsKey(m_ItemID))
return;
permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
permsMask = part.TaskInventory[m_ItemID].PermsMask;
}
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
{
ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter);
if (presence != null)
presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID);