aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-11 21:43:17 +0000
committerTeravus Ovares2007-12-11 21:43:17 +0000
commitd67009a78b57bfa4029129d40d23f8f16d3d8da6 (patch)
treed3048ba8bf7593288158d95337ff928e5a410376 /OpenSim/Region/Environment/Scenes
parentforce a flush before client shutdown, so no important packets are lost (diff)
downloadopensim-SC_OLD-d67009a78b57bfa4029129d40d23f8f16d3d8da6.zip
opensim-SC_OLD-d67009a78b57bfa4029129d40d23f8f16d3d8da6.tar.gz
opensim-SC_OLD-d67009a78b57bfa4029129d40d23f8f16d3d8da6.tar.bz2
opensim-SC_OLD-d67009a78b57bfa4029129d40d23f8f16d3d8da6.tar.xz
* Added some locking to help race conditions in the neighbors lists
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs72
1 files changed, 42 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 324b7d3..5febce6 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -284,8 +284,6 @@ namespace OpenSim.Region.Environment.Scenes
284 284
285 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 285 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
286 { 286 {
287 if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1))
288 {
289 for (int i = 0; i < m_neighbours.Count; i++) 287 for (int i = 0; i < m_neighbours.Count; i++)
290 { 288 {
291 // The purpose of this loop is to re-update the known neighbors 289 // The purpose of this loop is to re-update the known neighbors
@@ -295,7 +293,10 @@ namespace OpenSim.Region.Environment.Scenes
295 // Additionally, the commFailTF property gets reset to false. 293 // Additionally, the commFailTF property gets reset to false.
296 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) 294 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
297 { 295 {
298 m_neighbours[i] = otherRegion; 296 lock (m_neighbours)
297 {
298 m_neighbours[i] = otherRegion;
299 }
299 } 300 }
300 } 301 }
301 302
@@ -305,16 +306,24 @@ namespace OpenSim.Region.Environment.Scenes
305 306
306 if (!(m_neighbours.Contains(otherRegion))) 307 if (!(m_neighbours.Contains(otherRegion)))
307 { 308 {
308 m_neighbours.Add(otherRegion); 309 lock (m_neighbours)
310 {
311 m_neighbours.Add(otherRegion);
312 }
309 } 313 }
310 if (!(m_regionRestartNotifyList.Contains(otherRegion))) 314 if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1))
315 {
316 lock (m_regionRestartNotifyList)
311 { 317 {
312 m_regionRestartNotifyList.Add(otherRegion); 318 if (!(m_regionRestartNotifyList.Contains(otherRegion)))
319 {
320 m_regionRestartNotifyList.Add(otherRegion);
313 321
314 m_restartWaitTimer.Interval = 50000; 322 m_restartWaitTimer.Interval = 50000;
315 m_restartWaitTimer.AutoReset = false; 323 m_restartWaitTimer.AutoReset = false;
316 m_restartWaitTimer.Elapsed += new ElapsedEventHandler(RestartNotifyWaitElapsed); 324 m_restartWaitTimer.Elapsed += new ElapsedEventHandler(RestartNotifyWaitElapsed);
317 m_restartWaitTimer.Start(); 325 m_restartWaitTimer.Start();
326 }
318 } 327 }
319 } 328 }
320 else 329 else
@@ -394,33 +403,36 @@ namespace OpenSim.Region.Environment.Scenes
394 public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e) 403 public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e)
395 { 404 {
396 m_restartWaitTimer.Stop(); 405 m_restartWaitTimer.Stop();
397 foreach (RegionInfo region in m_regionRestartNotifyList) 406 lock (m_regionRestartNotifyList)
398 { 407 {
399 try 408 foreach (RegionInfo region in m_regionRestartNotifyList)
400 { 409 {
401 410 try
402 ForEachScenePresence(delegate(ScenePresence agent)
403 { 411 {
404 // If agent is a root agent. 412
405 if (!agent.IsChildAgent) 413 ForEachScenePresence(delegate(ScenePresence agent)
406 { 414 {
407 //agent.ControllingClient.new 415 // If agent is a root agent.
408 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 416 if (!agent.IsChildAgent)
409 InformClientOfNeighbor(agent, region); 417 {
418 //agent.ControllingClient.new
419 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
420 InformClientOfNeighbor(agent, region);
421 }
410 } 422 }
411 }
412 423
413 ); 424 );
414 } 425 }
415 catch (System.NullReferenceException) 426 catch (System.NullReferenceException)
416 { 427 {
417 // This means that we're not booted up completely yet. 428 // This means that we're not booted up completely yet.
418 // This shouldn't happen too often anymore. 429 // This shouldn't happen too often anymore.
430 }
419 } 431 }
420 }
421 432
422 // Reset list to nothing. 433 // Reset list to nothing.
423 m_regionRestartNotifyList.Clear(); 434 m_regionRestartNotifyList.Clear();
435 }
424 } 436 }
425 437
426 // This is the method that shuts down the scene. 438 // This is the method that shuts down the scene.
@@ -444,7 +456,7 @@ namespace OpenSim.Region.Environment.Scenes
444 // Stop all client threads. 456 // Stop all client threads.
445 ForEachScenePresence(delegate(ScenePresence avatar) 457 ForEachScenePresence(delegate(ScenePresence avatar)
446 { 458 {
447 avatar.ControllingClient.Stop(); 459 avatar.ControllingClient.Close();
448 }); 460 });
449 // Stop updating the scene objects and agents. 461 // Stop updating the scene objects and agents.
450 m_heartbeatTimer.Close(); 462 m_heartbeatTimer.Close();