Another stab at http://opensimulator.org/mantis/view.php?id=4858. Eliminated more nested locks.

0.7-release
Diva Canto 2010-07-19 15:20:34 -07:00
parent 699d3b0965
commit 257a46dfb9
1 changed files with 41 additions and 33 deletions

View File

@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
ScriptInstance instance = null;
lock (m_Scripts) lock (m_Scripts)
{ {
ScriptInstance instance = null;
// Create the object record // Create the object record
if ((!m_Scripts.ContainsKey(itemID)) || if ((!m_Scripts.ContainsKey(itemID)) ||
@ -784,28 +784,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_Scripts[itemID] = instance; m_Scripts[itemID] = instance;
} }
lock (m_PrimObjects)
{
if (!m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID] = new List<UUID>();
if (!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID);
}
if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assembly;
lock (m_AddingAssemblies)
{
m_AddingAssemblies[assembly]--;
}
if (instance!=null)
instance.Init();
} }
lock (m_PrimObjects)
{
if (!m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID] = new List<UUID>();
if (!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID);
}
if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assembly;
lock (m_AddingAssemblies)
{
m_AddingAssemblies[assembly]--;
}
if (instance != null)
instance.Init();
return true; return true;
} }
@ -1005,26 +1006,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public bool PostObjectEvent(uint localID, EventParams p) public bool PostObjectEvent(uint localID, EventParams p)
{ {
bool result = false; bool result = false;
List<UUID> uuids = null;
lock (m_PrimObjects) lock (m_PrimObjects)
{ {
if (!m_PrimObjects.ContainsKey(localID)) if (!m_PrimObjects.ContainsKey(localID))
return false; return false;
uuids = m_PrimObjects[localID];
foreach (UUID itemID in m_PrimObjects[localID]) }
foreach (UUID itemID in uuids)
{
IScriptInstance instance = null;
try
{ {
if (m_Scripts.ContainsKey(itemID)) if (m_Scripts.ContainsKey(itemID))
{ instance = m_Scripts[itemID];
IScriptInstance instance = m_Scripts[itemID]; }
if (instance != null) catch { /* ignore race conditions */ }
{
instance.PostEvent(p); if (instance != null)
result = true; {
} instance.PostEvent(p);
} result = true;
} }
} }
return result; return result;
} }