diff options
author | Justin Clark-Casey (justincc) | 2010-08-28 00:40:33 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-28 00:40:33 +0100 |
commit | 1c0b4457cdcd543f04bc818a987f6e3f2311098d (patch) | |
tree | 56b6a949423b5ca0f54b2c200e037052a9ac3ff0 /OpenSim/Region/Framework | |
parent | minor: reduce log chattiness of "load iar" for IARs with lots of folders (diff) | |
download | opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.zip opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.tar.gz opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.tar.bz2 opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.tar.xz |
Improve liveness by operating on list copies of SOG.Children where appropriate
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 22 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 15 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 21 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 51 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 50 |
5 files changed, 84 insertions, 75 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 8ed8b96..2ac46e2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -2004,11 +2004,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | sog.SetGroup(groupID, remoteClient); | 2004 | sog.SetGroup(groupID, remoteClient); |
2005 | sog.ScheduleGroupForFullUpdate(); | 2005 | sog.ScheduleGroupForFullUpdate(); |
2006 | 2006 | ||
2007 | List<SceneObjectPart> partList = null; | ||
2007 | lock (sog.Children) | 2008 | lock (sog.Children) |
2008 | { | 2009 | partList = new List<SceneObjectPart>(sog.Children.Values); |
2009 | foreach (SceneObjectPart child in sog.Children.Values) | 2010 | |
2010 | child.Inventory.ChangeInventoryOwner(ownerID); | 2011 | foreach (SceneObjectPart child in partList) |
2011 | } | 2012 | child.Inventory.ChangeInventoryOwner(ownerID); |
2012 | } | 2013 | } |
2013 | else | 2014 | else |
2014 | { | 2015 | { |
@@ -2017,14 +2018,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2017 | 2018 | ||
2018 | if (sog.GroupID != groupID) | 2019 | if (sog.GroupID != groupID) |
2019 | continue; | 2020 | continue; |
2020 | 2021 | ||
2022 | List<SceneObjectPart> partList = null; | ||
2021 | lock (sog.Children) | 2023 | lock (sog.Children) |
2024 | partList = new List<SceneObjectPart>(sog.Children.Values); | ||
2025 | |||
2026 | foreach (SceneObjectPart child in partList) | ||
2022 | { | 2027 | { |
2023 | foreach (SceneObjectPart child in sog.Children.Values) | 2028 | child.LastOwnerID = child.OwnerID; |
2024 | { | 2029 | child.Inventory.ChangeInventoryOwner(groupID); |
2025 | child.LastOwnerID = child.OwnerID; | ||
2026 | child.Inventory.ChangeInventoryOwner(groupID); | ||
2027 | } | ||
2028 | } | 2030 | } |
2029 | 2031 | ||
2030 | sog.SetOwnerId(groupID); | 2032 | sog.SetOwnerId(groupID); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 9f1575d..c511774 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -164,16 +164,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
164 | 164 | ||
165 | SceneObjectGroup sog = ent as SceneObjectGroup; | 165 | SceneObjectGroup sog = ent as SceneObjectGroup; |
166 | 166 | ||
167 | List<SceneObjectPart> partList = null; | ||
167 | lock (sog.Children) | 168 | lock (sog.Children) |
169 | partList = new List<SceneObjectPart>(sog.Children.Values); | ||
170 | |||
171 | foreach (SceneObjectPart part in partList) | ||
168 | { | 172 | { |
169 | foreach (KeyValuePair<UUID, SceneObjectPart> child in (sog.Children)) | 173 | if (part.LocalId == primLocalID) |
170 | { | 174 | { |
171 | if (child.Value.LocalId == primLocalID) | 175 | part.GetProperties(remoteClient); |
172 | { | 176 | foundPrim = true; |
173 | child.Value.GetProperties(remoteClient); | 177 | break; |
174 | foundPrim = true; | ||
175 | break; | ||
176 | } | ||
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5fe944d..db081cc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2065,19 +2065,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2065 | group.RemoveScriptInstances(true); | 2065 | group.RemoveScriptInstances(true); |
2066 | } | 2066 | } |
2067 | 2067 | ||
2068 | List<SceneObjectPart> partList = null; | ||
2068 | lock (group.Children) | 2069 | lock (group.Children) |
2070 | partList = new List<SceneObjectPart>(group.Children.Values); | ||
2071 | |||
2072 | foreach (SceneObjectPart part in partList) | ||
2069 | { | 2073 | { |
2070 | foreach (SceneObjectPart part in group.Children.Values) | 2074 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2071 | { | 2075 | { |
2072 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) | 2076 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? |
2073 | { | 2077 | } |
2074 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? | 2078 | else if (part.PhysActor != null) |
2075 | } | 2079 | { |
2076 | else if (part.PhysActor != null) | 2080 | PhysicsScene.RemovePrim(part.PhysActor); |
2077 | { | 2081 | part.PhysActor = null; |
2078 | PhysicsScene.RemovePrim(part.PhysActor); | ||
2079 | part.PhysActor = null; | ||
2080 | } | ||
2081 | } | 2082 | } |
2082 | } | 2083 | } |
2083 | 2084 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 9db2691..2c242c9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -380,34 +380,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
380 | part.Shape.Scale = scale; | 380 | part.Shape.Scale = scale; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | |||
384 | m_numPrim += sceneObject.Children.Count; | ||
385 | } | ||
383 | 386 | ||
384 | sceneObject.AttachToScene(m_parentScene); | 387 | sceneObject.AttachToScene(m_parentScene); |
385 | 388 | ||
386 | if (sendClientUpdates) | 389 | if (sendClientUpdates) |
387 | sceneObject.ScheduleGroupForFullUpdate(); | 390 | sceneObject.ScheduleGroupForFullUpdate(); |
388 | 391 | ||
389 | Entities.Add(sceneObject); | 392 | Entities.Add(sceneObject); |
390 | m_numPrim += sceneObject.Children.Count; | 393 | |
391 | 394 | if (attachToBackup) | |
392 | if (attachToBackup) | 395 | sceneObject.AttachToBackup(); |
393 | sceneObject.AttachToBackup(); | 396 | |
394 | 397 | if (OnObjectCreate != null) | |
395 | if (OnObjectCreate != null) | 398 | OnObjectCreate(sceneObject); |
396 | OnObjectCreate(sceneObject); | 399 | |
400 | lock (SceneObjectGroupsByFullID) | ||
401 | { | ||
402 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; | ||
403 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
404 | SceneObjectGroupsByFullID[part.UUID] = sceneObject; | ||
405 | } | ||
397 | 406 | ||
398 | lock (SceneObjectGroupsByFullID) | 407 | lock (SceneObjectGroupsByLocalID) |
399 | { | 408 | { |
400 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; | 409 | SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; |
401 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 410 | foreach (SceneObjectPart part in sceneObject.Children.Values) |
402 | SceneObjectGroupsByFullID[part.UUID] = sceneObject; | 411 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; |
403 | } | ||
404 | |||
405 | lock (SceneObjectGroupsByLocalID) | ||
406 | { | ||
407 | SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; | ||
408 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
409 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; | ||
410 | } | ||
411 | } | 412 | } |
412 | } | 413 | } |
413 | 414 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fc5eeed..40a8f83 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -237,6 +237,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | 237 | ||
238 | /// <value> | 238 | /// <value> |
239 | /// The parts of this scene object group. You must lock this property before using it. | 239 | /// The parts of this scene object group. You must lock this property before using it. |
240 | /// If you're doing anything other than reading values, please take a copy of the values rather than locking | ||
241 | /// the dictionary for the entirety of the operation. This increases liveness and reduces the danger of deadlock | ||
240 | /// If you want to know the number of children, consider using the PrimCount property instead | 242 | /// If you want to know the number of children, consider using the PrimCount property instead |
241 | /// </value> | 243 | /// </value> |
242 | public Dictionary<UUID, SceneObjectPart> Children | 244 | public Dictionary<UUID, SceneObjectPart> Children |
@@ -1968,28 +1970,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1968 | //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 1970 | //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
1969 | // return; | 1971 | // return; |
1970 | 1972 | ||
1971 | lock (m_parts) | 1973 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); |
1972 | { | ||
1973 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | ||
1974 | 1974 | ||
1975 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) | 1975 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) |
1976 | { | 1976 | { |
1977 | m_rootPart.UpdateFlag = 1; | 1977 | m_rootPart.UpdateFlag = 1; |
1978 | lastPhysGroupPos = AbsolutePosition; | 1978 | lastPhysGroupPos = AbsolutePosition; |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) | 1981 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) |
1982 | { | 1982 | { |
1983 | m_rootPart.UpdateFlag = 1; | 1983 | m_rootPart.UpdateFlag = 1; |
1984 | lastPhysGroupRot = GroupRotation; | 1984 | lastPhysGroupRot = GroupRotation; |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | foreach (SceneObjectPart part in m_parts.Values) | 1987 | List<SceneObjectPart> partList = null; |
1988 | { | 1988 | lock (m_parts) |
1989 | if (!IsSelected) | 1989 | partList = new List<SceneObjectPart>(m_parts.Values); |
1990 | part.UpdateLookAt(); | 1990 | |
1991 | part.SendScheduledUpdates(); | 1991 | foreach (SceneObjectPart part in partList) |
1992 | } | 1992 | { |
1993 | if (!IsSelected) | ||
1994 | part.UpdateLookAt(); | ||
1995 | part.SendScheduledUpdates(); | ||
1993 | } | 1996 | } |
1994 | } | 1997 | } |
1995 | 1998 | ||
@@ -2787,11 +2790,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2787 | public void UpdatePermissions(UUID AgentID, byte field, uint localID, | 2790 | public void UpdatePermissions(UUID AgentID, byte field, uint localID, |
2788 | uint mask, byte addRemTF) | 2791 | uint mask, byte addRemTF) |
2789 | { | 2792 | { |
2793 | List<SceneObjectPart> partList = null; | ||
2790 | lock (m_parts) | 2794 | lock (m_parts) |
2791 | { | 2795 | partList = new List<SceneObjectPart>(m_parts.Values); |
2792 | foreach (SceneObjectPart part in m_parts.Values) | 2796 | |
2793 | part.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 2797 | foreach (SceneObjectPart part in partList) |
2794 | } | 2798 | part.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2795 | 2799 | ||
2796 | HasGroupChanged = true; | 2800 | HasGroupChanged = true; |
2797 | } | 2801 | } |