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.
0.7.6-extended
Justin Clark-Casey (justincc) 2013-08-25 20:17:04 +01:00
parent b92128b715
commit 3f8a99937e
1 changed files with 22 additions and 10 deletions

View File

@ -46,8 +46,8 @@ namespace OpenSim.Region.CoreModules.World.Region
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")]
public class RestartModule : INonSharedRegionModule, IRestartModule public class RestartModule : INonSharedRegionModule, IRestartModule
{ {
// private static readonly ILog m_log = private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_Scene; protected Scene m_Scene;
protected Timer m_CountdownTimer = null; protected Timer m_CountdownTimer = null;
@ -202,6 +202,8 @@ namespace OpenSim.Region.CoreModules.World.Region
} }
public void SetTimer(int intervalSeconds) public void SetTimer(int intervalSeconds)
{
if (intervalSeconds > 0)
{ {
m_CountdownTimer = new Timer(); m_CountdownTimer = new Timer();
m_CountdownTimer.AutoReset = false; m_CountdownTimer.AutoReset = false;
@ -209,12 +211,22 @@ namespace OpenSim.Region.CoreModules.World.Region
m_CountdownTimer.Elapsed += OnTimer; m_CountdownTimer.Elapsed += OnTimer;
m_CountdownTimer.Start(); 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) private void OnTimer(object source, ElapsedEventArgs e)
{ {
int nextInterval = DoOneNotice(); SetTimer(DoOneNotice());
SetTimer(nextInterval);
} }
public void AbortRestart(string message) public void AbortRestart(string message)