From 8031f8ec09df4f654c86a9c7bc498664f7b9d9dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Aug 2010 00:08:53 +0100 Subject: Improve consistency of locking for SOG.m_parts in order to avoid race conditions in linking and unlinking --- .../OptionalModules/Scripting/Minimodule/SOPObject.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 96cccb7..34171b0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -185,14 +185,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { SceneObjectPart my = GetSOP(); - int total = my.ParentGroup.Children.Count; - - IObject[] rets = new IObject[total]; - - int i = 0; - foreach (KeyValuePair pair in my.ParentGroup.Children) + IObject[] rets = null; + + lock (my.ParentGroup.Children) { - rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); + int total = my.ParentGroup.Children.Count; + + rets = new IObject[total]; + + int i = 0; + foreach (KeyValuePair pair in my.ParentGroup.Children) + { + rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); + } } return rets; -- cgit v1.1