* 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,12 +572,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_Scripts[itemID] = instance; m_Scripts[itemID] = instance;
} }
lock (m_PrimObjects)
{
if (!m_PrimObjects.ContainsKey(localID)) if (!m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID] = new List<UUID>(); 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,6 +608,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (part != null) if (part != null)
part.RemoveScriptEvents(itemID); part.RemoveScriptEvents(itemID);
lock (m_PrimObjects)
{
// Remove the script from it's prim // Remove the script from it's prim
if (m_PrimObjects.ContainsKey(localID)) if (m_PrimObjects.ContainsKey(localID))
{ {
@ -617,6 +623,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_PrimObjects.Remove(localID); m_PrimObjects.Remove(localID);
} }
} }
}
m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
if (m_DomainScripts[instance.AppDomain].Count == 0) if (m_DomainScripts[instance.AppDomain].Count == 0)
@ -750,9 +757,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
bool result = false; bool result = false;
lock (m_PrimObjects)
{
if (!m_PrimObjects.ContainsKey(localID)) if (!m_PrimObjects.ContainsKey(localID))
return false; return false;
foreach (UUID itemID in m_PrimObjects[localID]) foreach (UUID itemID in m_PrimObjects[localID])
{ {
if (m_Scripts.ContainsKey(itemID)) if (m_Scripts.ContainsKey(itemID))
@ -765,6 +775,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
} }
}
return result; return result;
} }