From 3f8a99937e597cf63e346dd03c5c116fb8ee7bbc Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sun, 25 Aug 2013 20:17:04 +0100 Subject: [PATCH] Fix exception thrown after a region has been restarted through scheduling. This exception was very likely harmless since it occurred after the restart had taken place, but still misleading. Thanks to SCGreyWolf for the code change suggestion in http://opensimulator.org/mantis/view.php?id=6747, though I did this in a slightly different way. --- .../CoreModules/World/Region/RestartModule.cs | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 249a40db9e..75a8295760 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs @@ -46,8 +46,8 @@ namespace OpenSim.Region.CoreModules.World.Region [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")] public class RestartModule : INonSharedRegionModule, IRestartModule { -// private static readonly ILog m_log = -// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_Scene; protected Timer m_CountdownTimer = null; @@ -203,18 +203,30 @@ namespace OpenSim.Region.CoreModules.World.Region public void SetTimer(int intervalSeconds) { - m_CountdownTimer = new Timer(); - m_CountdownTimer.AutoReset = false; - m_CountdownTimer.Interval = intervalSeconds * 1000; - m_CountdownTimer.Elapsed += OnTimer; - m_CountdownTimer.Start(); + if (intervalSeconds > 0) + { + m_CountdownTimer = new Timer(); + m_CountdownTimer.AutoReset = false; + m_CountdownTimer.Interval = intervalSeconds * 1000; + m_CountdownTimer.Elapsed += OnTimer; + m_CountdownTimer.Start(); + } + else if (m_CountdownTimer != null) + { + m_CountdownTimer.Stop(); + m_CountdownTimer = null; + } + else + { + m_log.WarnFormat( + "[RESTART MODULE]: Tried to set restart timer to {0} in {1}, which is not a valid interval", + intervalSeconds, m_Scene.Name); + } } private void OnTimer(object source, ElapsedEventArgs e) { - int nextInterval = DoOneNotice(); - - SetTimer(nextInterval); + SetTimer(DoOneNotice()); } public void AbortRestart(string message)