change scenegraph locking

0.9.1.0-post-fixes
UbitUmarov 2019-01-06 01:44:37 +00:00
parent c5604d3857
commit 3e49e13249
1 changed files with 70 additions and 53 deletions

View File

@ -150,9 +150,14 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void Close() protected internal void Close()
{ {
m_scenePresencesLock.EnterWriteLock(); bool entered = false;
try try
{ {
try { }
finally
{
m_scenePresencesLock.EnterWriteLock();
entered = true;
m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>();
m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>();
m_scenePresenceArray = new List<ScenePresence>(); m_scenePresenceArray = new List<ScenePresence>();
@ -162,8 +167,10 @@ namespace OpenSim.Region.Framework.Scenes
_PhyScene.OnPhysicsCrash -= physicsBasedCrash; _PhyScene.OnPhysicsCrash -= physicsBasedCrash;
_PhyScene = null; _PhyScene = null;
} }
}
finally finally
{ {
if(entered)
m_scenePresencesLock.ExitWriteLock(); m_scenePresencesLock.ExitWriteLock();
} }
@ -707,6 +714,9 @@ namespace OpenSim.Region.Framework.Scenes
bool entered = false; bool entered = false;
try try
{
try{ }
finally
{ {
m_scenePresencesLock.EnterWriteLock(); m_scenePresencesLock.EnterWriteLock();
entered = true; entered = true;
@ -735,6 +745,7 @@ namespace OpenSim.Region.Framework.Scenes
++m_spArrayVersion; ++m_spArrayVersion;
} }
}
finally finally
{ {
if(entered) if(entered)
@ -758,6 +769,9 @@ namespace OpenSim.Region.Framework.Scenes
bool entered = false; bool entered = false;
try try
{
try { }
finally
{ {
m_scenePresencesLock.EnterWriteLock(); m_scenePresencesLock.EnterWriteLock();
entered = true; entered = true;
@ -774,6 +788,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
} }
} }
}
finally finally
{ {
if(entered) if(entered)
@ -905,7 +920,11 @@ namespace OpenSim.Region.Framework.Scenes
protected internal List<ScenePresence> GetScenePresences() protected internal List<ScenePresence> GetScenePresences()
{ {
bool entered = false; bool entered = false;
List<ScenePresence> ret = new List<ScenePresence>();
try try
{
try{ }
finally
{ {
m_scenePresencesLock.EnterWriteLock(); m_scenePresencesLock.EnterWriteLock();
entered = true; entered = true;
@ -914,17 +933,15 @@ namespace OpenSim.Region.Framework.Scenes
m_scenePresenceArray = new List<ScenePresence>(m_scenePresenceMap.Values); m_scenePresenceArray = new List<ScenePresence>(m_scenePresenceMap.Values);
m_spArrayLastVersion = m_spArrayVersion; m_spArrayLastVersion = m_spArrayVersion;
} }
return m_scenePresenceArray; ret = m_scenePresenceArray;
} }
catch
{
return new List<ScenePresence>();
} }
finally finally
{ {
if(entered) if(entered)
m_scenePresencesLock.ExitWriteLock(); m_scenePresencesLock.ExitWriteLock();
} }
return ret;
} }
/// <summary> /// <summary>