aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-12-17 15:30:26 +0000
committerTeravus Ovares2008-12-17 15:30:26 +0000
commitca0de93d9a54afc59298454db9ca49fb5d35c12b (patch)
tree56ce57805bd156b85ef745356692ae42f3ffc7e8 /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
parentStop users taking a copy of a in world prim that contains inventory items tha... (diff)
downloadopensim-SC-ca0de93d9a54afc59298454db9ca49fb5d35c12b.zip
opensim-SC-ca0de93d9a54afc59298454db9ca49fb5d35c12b.tar.gz
opensim-SC-ca0de93d9a54afc59298454db9ca49fb5d35c12b.tar.bz2
opensim-SC-ca0de93d9a54afc59298454db9ca49fb5d35c12b.tar.xz
* Adding some locks to XEngine's m_PrimObjects which were prone to 'the collection was modified'
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs57
1 files changed, 34 insertions, 23 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 3c3eb19..6ad8923 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -572,11 +572,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
572 m_Scripts[itemID] = instance; 572 m_Scripts[itemID] = instance;
573 } 573 }
574 574
575 if (!m_PrimObjects.ContainsKey(localID)) 575 lock (m_PrimObjects)
576 m_PrimObjects[localID] = new List<UUID>(); 576 {
577 if (!m_PrimObjects.ContainsKey(localID))
578 m_PrimObjects[localID] = new List<UUID>();
577 579
578 if (!m_PrimObjects[localID].Contains(itemID)) 580 if (!m_PrimObjects[localID].Contains(itemID))
579 m_PrimObjects[localID].Add(itemID); 581 m_PrimObjects[localID].Add(itemID);
582
583 }
580 584
581 if (!m_Assemblies.ContainsKey(assetID)) 585 if (!m_Assemblies.ContainsKey(assetID))
582 m_Assemblies[assetID] = assembly; 586 m_Assemblies[assetID] = assembly;
@@ -604,17 +608,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
604 if (part != null) 608 if (part != null)
605 part.RemoveScriptEvents(itemID); 609 part.RemoveScriptEvents(itemID);
606 610
607 // Remove the script from it's prim 611 lock (m_PrimObjects)
608 if (m_PrimObjects.ContainsKey(localID))
609 { 612 {
610 // Remove inventory item record 613 // Remove the script from it's prim
611 if (m_PrimObjects[localID].Contains(itemID)) 614 if (m_PrimObjects.ContainsKey(localID))
612 m_PrimObjects[localID].Remove(itemID);
613
614 // If there are no more scripts, remove prim
615 if (m_PrimObjects[localID].Count == 0)
616 { 615 {
617 m_PrimObjects.Remove(localID); 616 // Remove inventory item record
617 if (m_PrimObjects[localID].Contains(itemID))
618 m_PrimObjects[localID].Remove(itemID);
619
620 // If there are no more scripts, remove prim
621 if (m_PrimObjects[localID].Count == 0)
622 {
623 m_PrimObjects.Remove(localID);
624 }
618 } 625 }
619 } 626 }
620 627
@@ -749,19 +756,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
749 public bool PostObjectEvent(uint localID, EventParams p) 756 public bool PostObjectEvent(uint localID, EventParams p)
750 { 757 {
751 bool result = false; 758 bool result = false;
752 759
753 if (!m_PrimObjects.ContainsKey(localID)) 760 lock (m_PrimObjects)
754 return false;
755
756 foreach (UUID itemID in m_PrimObjects[localID])
757 { 761 {
758 if (m_Scripts.ContainsKey(itemID)) 762 if (!m_PrimObjects.ContainsKey(localID))
763 return false;
764
765
766 foreach (UUID itemID in m_PrimObjects[localID])
759 { 767 {
760 IScriptInstance instance = m_Scripts[itemID]; 768 if (m_Scripts.ContainsKey(itemID))
761 if (instance != null)
762 { 769 {
763 instance.PostEvent(p); 770 IScriptInstance instance = m_Scripts[itemID];
764 result = true; 771 if (instance != null)
772 {
773 instance.PostEvent(p);
774 result = true;
775 }
765 } 776 }
766 } 777 }
767 } 778 }