* Added some locking to help race conditions in the neighbors lists

afrisby
Teravus Ovares 2007-12-11 21:43:17 +00:00
parent 1fd62bc1af
commit d67009a78b
1 changed files with 42 additions and 30 deletions

View File

@ -283,8 +283,6 @@ namespace OpenSim.Region.Environment.Scenes
if (RegionInfo.RegionHandle != otherRegion.RegionHandle) if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
{
if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1))
{ {
for (int i = 0; i < m_neighbours.Count; i++) for (int i = 0; i < m_neighbours.Count; i++)
{ {
@ -294,19 +292,29 @@ namespace OpenSim.Region.Environment.Scenes
// 'known neighbors list' // 'known neighbors list'
// Additionally, the commFailTF property gets reset to false. // Additionally, the commFailTF property gets reset to false.
if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
{
lock (m_neighbours)
{ {
m_neighbours[i] = otherRegion; m_neighbours[i] = otherRegion;
} }
} }
}
// If the value isn't in the neighbours, add it. // If the value isn't in the neighbours, add it.
// If the RegionInfo isn't exact but is for the same XY World location, // If the RegionInfo isn't exact but is for the same XY World location,
// then the above loop will fix that. // then the above loop will fix that.
if (!(m_neighbours.Contains(otherRegion))) if (!(m_neighbours.Contains(otherRegion)))
{
lock (m_neighbours)
{ {
m_neighbours.Add(otherRegion); m_neighbours.Add(otherRegion);
} }
}
if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1))
{
lock (m_regionRestartNotifyList)
{
if (!(m_regionRestartNotifyList.Contains(otherRegion))) if (!(m_regionRestartNotifyList.Contains(otherRegion)))
{ {
m_regionRestartNotifyList.Add(otherRegion); m_regionRestartNotifyList.Add(otherRegion);
@ -317,6 +325,7 @@ namespace OpenSim.Region.Environment.Scenes
m_restartWaitTimer.Start(); m_restartWaitTimer.Start();
} }
} }
}
else else
{ {
MainLog.Instance.Verbose("INTERGRID", "Got notice about Region at X:" + otherRegion.RegionLocX.ToString() + " Y:" + otherRegion.RegionLocY.ToString() + " but it was too far away to send to the client"); MainLog.Instance.Verbose("INTERGRID", "Got notice about Region at X:" + otherRegion.RegionLocX.ToString() + " Y:" + otherRegion.RegionLocY.ToString() + " but it was too far away to send to the client");
@ -394,6 +403,8 @@ namespace OpenSim.Region.Environment.Scenes
public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e) public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e)
{ {
m_restartWaitTimer.Stop(); m_restartWaitTimer.Stop();
lock (m_regionRestartNotifyList)
{
foreach (RegionInfo region in m_regionRestartNotifyList) foreach (RegionInfo region in m_regionRestartNotifyList)
{ {
try try
@ -422,6 +433,7 @@ namespace OpenSim.Region.Environment.Scenes
// Reset list to nothing. // Reset list to nothing.
m_regionRestartNotifyList.Clear(); m_regionRestartNotifyList.Clear();
} }
}
// This is the method that shuts down the scene. // This is the method that shuts down the scene.
public override void Close() public override void Close()
@ -444,7 +456,7 @@ namespace OpenSim.Region.Environment.Scenes
// Stop all client threads. // Stop all client threads.
ForEachScenePresence(delegate(ScenePresence avatar) ForEachScenePresence(delegate(ScenePresence avatar)
{ {
avatar.ControllingClient.Stop(); avatar.ControllingClient.Close();
}); });
// Stop updating the scene objects and agents. // Stop updating the scene objects and agents.
m_heartbeatTimer.Close(); m_heartbeatTimer.Close();