From 5c012cac54f92f2881005a50fd3eb103f0f2ea07 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 25 Jul 2011 04:16:53 +0200 Subject: [PATCH] Add a timer to monitor the heartbeat. Restart it if it's been dead for 5 seconds. --- OpenSim/Region/Application/OpenSimBase.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 04a68ae4a9..dbfd0f2290 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -487,6 +487,7 @@ namespace OpenSim } scene.StartTimer(); + scene.StartTimerWatchdog(); return clientServer; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e02a866c4a..ec82cc3553 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -109,6 +109,7 @@ namespace OpenSim.Region.Framework.Scenes protected int m_splitRegionID; protected Timer m_restartWaitTimer = new Timer(); + protected Timer m_timerWatchdog = new Timer(); protected List m_regionRestartNotifyList = new List(); protected List m_neighbours = new List(); protected string m_simulatorVersion = "OpenSimulator Server"; @@ -191,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scripts_enabled = true; private string m_defaultScriptEngine; private int m_LastLogin; - private Thread HeartbeatThread; + private Thread HeartbeatThread = null; private volatile bool shuttingdown; private int m_lastUpdate; @@ -4886,7 +4887,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_firstHeartbeat) return; - if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) + if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) StartTimer(); } @@ -5380,5 +5381,18 @@ namespace OpenSim.Region.Framework.Scenes reason = String.Empty; return true; } + + public void StartTimerWatchdog() + { + m_timerWatchdog.Interval = 1000; + m_timerWatchdog.Elapsed += TimerWatchdog; + m_timerWatchdog.AutoReset = true; + m_timerWatchdog.Start(); + } + + public void TimerWatchdog(object sender, ElapsedEventArgs e) + { + CheckHeartbeat(); + } } }