aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorUbitUmarov2019-01-01 13:16:35 +0000
committerUbitUmarov2019-01-01 13:16:35 +0000
commit9c043fe41401c6334b69ef7c19001ecfc6cf8934 (patch)
tree150c1cadbbcb523e0eecc52ca38253488a5aaceb /OpenSim/Region/Framework
parentreplace my hack by others hack (diff)
downloadopensim-SC-9c043fe41401c6334b69ef7c19001ecfc6cf8934.zip
opensim-SC-9c043fe41401c6334b69ef7c19001ecfc6cf8934.tar.gz
opensim-SC-9c043fe41401c6334b69ef7c19001ecfc6cf8934.tar.bz2
opensim-SC-9c043fe41401c6334b69ef7c19001ecfc6cf8934.tar.xz
mantis 8438: work around null ref
Diffstat (limited to 'OpenSim/Region/Framework')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs53
1 files changed, 26 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 6d9844e..66a5325 100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Region.Framework.Scenes
69 69
70 #region Fields 70 #region Fields
71 71
72 protected System.Threading.ReaderWriterLockSlim m_scenePresencesLock = new System.Threading.ReaderWriterLockSlim(); 72 protected System.Threading.ReaderWriterLockSlim m_scenePresencesLock;
73 73
74 protected ConcurrentDictionary<UUID, ScenePresence> m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); 74 protected ConcurrentDictionary<UUID, ScenePresence> m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>();
75 protected ConcurrentDictionary<uint, ScenePresence> m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); 75 protected ConcurrentDictionary<uint, ScenePresence> m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>();
@@ -119,6 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
119 119
120 protected internal SceneGraph(Scene parent) 120 protected internal SceneGraph(Scene parent)
121 { 121 {
122 m_scenePresencesLock = new System.Threading.ReaderWriterLockSlim();
122 m_parentScene = parent; 123 m_parentScene = parent;
123 } 124 }
124 125
@@ -153,6 +154,9 @@ namespace OpenSim.Region.Framework.Scenes
153 m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); 154 m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>();
154 m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); 155 m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>();
155 m_scenePresenceArray = new List<ScenePresence>(); 156 m_scenePresenceArray = new List<ScenePresence>();
157 if (_PhyScene != null)
158 _PhyScene.OnPhysicsCrash -= physicsBasedCrash;
159 _PhyScene = null;
156 } 160 }
157 finally 161 finally
158 { 162 {
@@ -168,6 +172,7 @@ namespace OpenSim.Region.Framework.Scenes
168 172
169 Entities.Clear(); 173 Entities.Clear();
170 m_scenePresencesLock.Dispose(); 174 m_scenePresencesLock.Dispose();
175 m_scenePresencesLock = null;
171 } 176 }
172 177
173 #region Update Methods 178 #region Update Methods
@@ -695,10 +700,13 @@ namespace OpenSim.Region.Framework.Scenes
695 ScenePresence presence = new ScenePresence(client, m_parentScene, appearance, type); 700 ScenePresence presence = new ScenePresence(client, m_parentScene, appearance, type);
696 701
697 Entities[presence.UUID] = presence; 702 Entities[presence.UUID] = presence;
703 bool entered = false;
698 704
699 m_scenePresencesLock.EnterWriteLock();
700 try 705 try
701 { 706 {
707 m_scenePresencesLock.EnterWriteLock();
708 entered = true;
709
702 m_numChildAgents++; 710 m_numChildAgents++;
703 711
704 List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); 712 List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray);
@@ -731,7 +739,8 @@ namespace OpenSim.Region.Framework.Scenes
731 } 739 }
732 finally 740 finally
733 { 741 {
734 m_scenePresencesLock.ExitWriteLock(); 742 if(entered)
743 m_scenePresencesLock.ExitWriteLock();
735 } 744 }
736 745
737 return presence; 746 return presence;
@@ -749,9 +758,11 @@ namespace OpenSim.Region.Framework.Scenes
749 agentID); 758 agentID);
750 } 759 }
751 760
752 m_scenePresencesLock.EnterWriteLock(); 761 bool entered = false;
753 try 762 try
754 { 763 {
764 m_scenePresencesLock.EnterWriteLock();
765 entered = true;
755 // Remove the presence reference from the dictionary 766 // Remove the presence reference from the dictionary
756 ScenePresence oldref; 767 ScenePresence oldref;
757 if(m_scenePresenceMap.TryRemove(agentID, out oldref)) 768 if(m_scenePresenceMap.TryRemove(agentID, out oldref))
@@ -769,7 +780,8 @@ namespace OpenSim.Region.Framework.Scenes
769 } 780 }
770 finally 781 finally
771 { 782 {
772 m_scenePresencesLock.ExitWriteLock(); 783 if(entered)
784 m_scenePresencesLock.ExitWriteLock();
773 } 785 }
774 } 786 }
775 787
@@ -896,15 +908,21 @@ namespace OpenSim.Region.Framework.Scenes
896 /// <returns></returns> 908 /// <returns></returns>
897 protected internal List<ScenePresence> GetScenePresences() 909 protected internal List<ScenePresence> GetScenePresences()
898 { 910 {
899 911 bool entered = false;
900 m_scenePresencesLock.EnterReadLock();
901 try 912 try
902 { 913 {
914 m_scenePresencesLock.EnterReadLock();
915 entered = true;
903 return m_scenePresenceArray; 916 return m_scenePresenceArray;
904 } 917 }
918 catch
919 {
920 return new List<ScenePresence>();
921 }
905 finally 922 finally
906 { 923 {
907 m_scenePresencesLock.ExitReadLock(); 924 if(entered)
925 m_scenePresencesLock.ExitReadLock();
908 } 926 }
909 } 927 }
910 928
@@ -1207,8 +1225,6 @@ namespace OpenSim.Region.Framework.Scenes
1207 { 1225 {
1208 foreach (SceneObjectPart p in ((SceneObjectGroup)entity).Parts) 1226 foreach (SceneObjectPart p in ((SceneObjectGroup)entity).Parts)
1209 { 1227 {
1210// m_log.DebugFormat("[SCENE GRAPH]: Part {0} has name {1}", p.UUID, p.Name);
1211
1212 if (p.Name == name) 1228 if (p.Name == name)
1213 { 1229 {
1214 sop = p; 1230 sop = p;
@@ -1312,23 +1328,6 @@ namespace OpenSim.Region.Framework.Scenes
1312 /// <param name="action"></param> 1328 /// <param name="action"></param>
1313 public void ForEachScenePresence(Action<ScenePresence> action) 1329 public void ForEachScenePresence(Action<ScenePresence> action)
1314 { 1330 {
1315 // Once all callers have their delegates configured for parallelism, we can unleash this
1316 /*
1317 Action<ScenePresence> protectedAction = new Action<ScenePresence>(delegate(ScenePresence sp)
1318 {
1319 try
1320 {
1321 action(sp);
1322 }
1323 catch (Exception e)
1324 {
1325 m_log.Info("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1326 m_log.Info("[SCENEGRAPH]: Stack Trace: " + e.StackTrace);
1327 }
1328 });
1329 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
1330 */
1331 // For now, perform actions serially
1332 List<ScenePresence> presences = GetScenePresences(); 1331 List<ScenePresence> presences = GetScenePresences();
1333 foreach (ScenePresence sp in presences) 1332 foreach (ScenePresence sp in presences)
1334 { 1333 {