* Adding some locks to XEngine's m_PrimObjects which were prone to 'the collection was modified'

0.6.1-post-fixes
Teravus Ovares 2008-12-17 15:30:26 +00:00
parent 027ae58dc4
commit ca0de93d9a
1 changed files with 34 additions and 23 deletions

View File

@ -572,11 +572,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_Scripts[itemID] = instance; m_Scripts[itemID] = instance;
} }
if (!m_PrimObjects.ContainsKey(localID)) lock (m_PrimObjects)
m_PrimObjects[localID] = new List<UUID>(); {
if (!m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID] = new List<UUID>();
if (!m_PrimObjects[localID].Contains(itemID)) if (!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID); m_PrimObjects[localID].Add(itemID);
}
if (!m_Assemblies.ContainsKey(assetID)) if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assembly; m_Assemblies[assetID] = assembly;
@ -604,17 +608,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (part != null) if (part != null)
part.RemoveScriptEvents(itemID); part.RemoveScriptEvents(itemID);
// Remove the script from it's prim lock (m_PrimObjects)
if (m_PrimObjects.ContainsKey(localID))
{ {
// Remove inventory item record // Remove the script from it's prim
if (m_PrimObjects[localID].Contains(itemID)) if (m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID].Remove(itemID);
// If there are no more scripts, remove prim
if (m_PrimObjects[localID].Count == 0)
{ {
m_PrimObjects.Remove(localID); // Remove inventory item record
if (m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Remove(itemID);
// If there are no more scripts, remove prim
if (m_PrimObjects[localID].Count == 0)
{
m_PrimObjects.Remove(localID);
}
} }
} }
@ -750,18 +757,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
bool result = false; bool result = false;
if (!m_PrimObjects.ContainsKey(localID)) lock (m_PrimObjects)
return false;
foreach (UUID itemID in m_PrimObjects[localID])
{ {
if (m_Scripts.ContainsKey(itemID)) if (!m_PrimObjects.ContainsKey(localID))
return false;
foreach (UUID itemID in m_PrimObjects[localID])
{ {
IScriptInstance instance = m_Scripts[itemID]; if (m_Scripts.ContainsKey(itemID))
if (instance != null)
{ {
instance.PostEvent(p); IScriptInstance instance = m_Scripts[itemID];
result = true; if (instance != null)
{
instance.PostEvent(p);
result = true;
}
} }
} }
} }