aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorJohn Hurliman2010-09-10 12:41:36 -0700
committerJohn Hurliman2010-09-10 12:41:36 -0700
commitb597a295c489cef217b9dca6bd22df1340ca39ce (patch)
treedbd74bb48f962fb7b64cc67db6df890451859782 /OpenSim/Region/Framework
parentFirst pass at cleaning up thread safety in EntityManager and SceneGraph (diff)
downloadopensim-SC_OLD-b597a295c489cef217b9dca6bd22df1340ca39ce.zip
opensim-SC_OLD-b597a295c489cef217b9dca6bd22df1340ca39ce.tar.gz
opensim-SC_OLD-b597a295c489cef217b9dca6bd22df1340ca39ce.tar.bz2
opensim-SC_OLD-b597a295c489cef217b9dca6bd22df1340ca39ce.tar.xz
Second pass at cleaning up thread safety in EntityManager and SceneGraph
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityManager.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs66
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs11
3 files changed, 35 insertions, 58 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index 85d0a4f..0defa93 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
34 34
35namespace OpenSim.Region.Framework.Scenes 35namespace OpenSim.Region.Framework.Scenes
36{ 36{
37 public class EntityManager //: IEnumerable<EntityBase> 37 public class EntityManager
38 { 38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>(); 40 private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>();
@@ -143,19 +143,5 @@ namespace OpenSim.Region.Framework.Scenes
143 { 143 {
144 return m_entities.TryGetValue(key, out obj); 144 return m_entities.TryGetValue(key, out obj);
145 } 145 }
146
147 /// <summary>
148 /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that.
149 /// </summary>
150 /// <returns></returns>
151 //public IEnumerator<EntityBase> GetEnumerator()
152 //{
153 // return GetEntities().GetEnumerator();
154 //}
155
156 //IEnumerator IEnumerable.GetEnumerator()
157 //{
158 // return GetEnumerator();
159 //}
160 } 146 }
161} 147}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 3d3e822..f779a6d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -72,10 +72,7 @@ namespace OpenSim.Region.Framework.Scenes
72 protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); 72 protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>();
73 protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); 73 protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>();
74 74
75 // SceneObjects is not currently populated or used.
76 //public Dictionary<UUID, SceneObjectGroup> SceneObjects;
77 protected internal EntityManager Entities = new EntityManager(); 75 protected internal EntityManager Entities = new EntityManager();
78// protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>();
79 protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); 76 protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>();
80 77
81 protected RegionInfo m_regInfo; 78 protected RegionInfo m_regInfo;
@@ -351,28 +348,28 @@ namespace OpenSim.Region.Framework.Scenes
351 if (Entities.ContainsKey(sceneObject.UUID)) 348 if (Entities.ContainsKey(sceneObject.UUID))
352 return false; 349 return false;
353 350
354 // Clamp child prim sizes and add child prims to the m_numPrim count 351 List<SceneObjectPart> children;
355 lock (sceneObject.Children) 352 lock (sceneObject.Children)
353 children = new List<SceneObjectPart>(sceneObject.Children.Values);
354
355 // Clamp child prim sizes and add child prims to the m_numPrim count
356 if (m_parentScene.m_clampPrimSize)
356 { 357 {
357 if (m_parentScene.m_clampPrimSize) 358 foreach (SceneObjectPart part in children)
358 { 359 {
359 foreach (SceneObjectPart part in sceneObject.Children.Values) 360 Vector3 scale = part.Shape.Scale;
360 {
361 Vector3 scale = part.Shape.Scale;
362 361
363 if (scale.X > m_parentScene.m_maxNonphys) 362 if (scale.X > m_parentScene.m_maxNonphys)
364 scale.X = m_parentScene.m_maxNonphys; 363 scale.X = m_parentScene.m_maxNonphys;
365 if (scale.Y > m_parentScene.m_maxNonphys) 364 if (scale.Y > m_parentScene.m_maxNonphys)
366 scale.Y = m_parentScene.m_maxNonphys; 365 scale.Y = m_parentScene.m_maxNonphys;
367 if (scale.Z > m_parentScene.m_maxNonphys) 366 if (scale.Z > m_parentScene.m_maxNonphys)
368 scale.Z = m_parentScene.m_maxNonphys; 367 scale.Z = m_parentScene.m_maxNonphys;
369 368
370 part.Shape.Scale = scale; 369 part.Shape.Scale = scale;
371 }
372 } 370 }
373
374 m_numPrim += sceneObject.Children.Count;
375 } 371 }
372 m_numPrim += children.Count;
376 373
377 sceneObject.AttachToScene(m_parentScene); 374 sceneObject.AttachToScene(m_parentScene);
378 375
@@ -390,14 +387,14 @@ namespace OpenSim.Region.Framework.Scenes
390 lock (SceneObjectGroupsByFullID) 387 lock (SceneObjectGroupsByFullID)
391 { 388 {
392 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; 389 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
393 foreach (SceneObjectPart part in sceneObject.Children.Values) 390 foreach (SceneObjectPart part in children)
394 SceneObjectGroupsByFullID[part.UUID] = sceneObject; 391 SceneObjectGroupsByFullID[part.UUID] = sceneObject;
395 } 392 }
396 393
397 lock (SceneObjectGroupsByLocalID) 394 lock (SceneObjectGroupsByLocalID)
398 { 395 {
399 SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; 396 SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject;
400 foreach (SceneObjectPart part in sceneObject.Children.Values) 397 foreach (SceneObjectPart part in children)
401 SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; 398 SceneObjectGroupsByLocalID[part.LocalId] = sceneObject;
402 } 399 }
403 400
@@ -859,13 +856,13 @@ namespace OpenSim.Region.Framework.Scenes
859 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); 856 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
860 SceneObjectGroup sog; 857 SceneObjectGroup sog;
861 lock (SceneObjectGroupsByLocalID) 858 lock (SceneObjectGroupsByLocalID)
859 SceneObjectGroupsByLocalID.TryGetValue(localID, out sog);
860
861 if (sog != null)
862 { 862 {
863 if (SceneObjectGroupsByLocalID.TryGetValue(localID, out sog)) 863 if (sog.HasChildPrim(localID))
864 { 864 return sog;
865 if (sog.HasChildPrim(localID)) 865 SceneObjectGroupsByLocalID.Remove(localID);
866 return sog;
867 SceneObjectGroupsByLocalID.Remove(localID);
868 }
869 } 866 }
870 867
871 EntityBase[] entityList = GetEntities(); 868 EntityBase[] entityList = GetEntities();
@@ -896,17 +893,18 @@ namespace OpenSim.Region.Framework.Scenes
896 { 893 {
897 SceneObjectGroup sog; 894 SceneObjectGroup sog;
898 lock (SceneObjectGroupsByFullID) 895 lock (SceneObjectGroupsByFullID)
896 SceneObjectGroupsByFullID.TryGetValue(fullID, out sog);
897
898 if (sog != null)
899 { 899 {
900 if (SceneObjectGroupsByFullID.TryGetValue(fullID, out sog)) 900 lock (sog.Children)
901 { 901 {
902 lock (sog.Children) 902 if (sog.Children.ContainsKey(fullID))
903 { 903 return sog;
904 if (sog.Children.ContainsKey(fullID))
905 return sog;
906 }
907
908 SceneObjectGroupsByFullID.Remove(fullID);
909 } 904 }
905
906 lock (SceneObjectGroupsByFullID)
907 SceneObjectGroupsByFullID.Remove(fullID);
910 } 908 }
911 909
912 EntityBase[] entityList = GetEntities(); 910 EntityBase[] entityList = GetEntities();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 09e3e0e..ba5e33c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2091,16 +2091,9 @@ namespace OpenSim.Region.Framework.Scenes
2091 /// <returns>null if a child part with the primID was not found</returns> 2091 /// <returns>null if a child part with the primID was not found</returns>
2092 public SceneObjectPart GetChildPart(UUID primID) 2092 public SceneObjectPart GetChildPart(UUID primID)
2093 { 2093 {
2094 SceneObjectPart childPart = null; 2094 SceneObjectPart childPart;
2095
2096 lock (m_parts) 2095 lock (m_parts)
2097 { 2096 m_parts.TryGetValue(primID, out childPart);
2098 if (m_parts.ContainsKey(primID))
2099 {
2100 childPart = m_parts[primID];
2101 }
2102 }
2103
2104 return childPart; 2097 return childPart;
2105 } 2098 }
2106 2099