From e93308072ea8ec106e429dc8071795018b58a75a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Jun 2012 16:32:07 +0200 Subject: [PATCH] Make the "delay restart" button delay restart for 1 hour rather than aborting it altogether. Allow a maximum of three uses before the restart goes through. --- .../World/Estate/EstateManagementModule.cs | 8 +- .../CoreModules/World/Region/RestartModule.cs | 83 ++++++++++++------- .../Framework/Interfaces/IRestartModule.cs | 1 + 3 files changed, 61 insertions(+), 31 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 1e743c3672..97a2f4a6f7 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -61,6 +61,8 @@ namespace OpenSim.Region.CoreModules.World.Estate public event ChangeDelegate OnEstateInfoChange; public event MessageDelegate OnEstateMessage; + private int m_delayCount = 0; + #region Packet Data Responders private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice) @@ -259,7 +261,11 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (timeInSeconds == -1) { - restartModule.AbortRestart("Restart aborted by region manager"); + m_delayCount++; + if (m_delayCount > 3) + return; + + restartModule.DelayRestart(3600, "Restart delayed by region manager"); return; } diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 65180b5a57..287738a5e1 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs @@ -59,6 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Region protected bool m_Notice = false; protected IDialogModule m_DialogModule = null; protected string m_MarkerPath = String.Empty; + private int[] m_CurrentAlerts = null; public void Initialise(IConfigSource config) { @@ -141,6 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Region m_Message = message; m_Initiator = initiator; m_Notice = notice; + m_CurrentAlerts = alerts; m_Alerts = new List(alerts); m_Alerts.Sort(); m_Alerts.Reverse(); @@ -152,12 +154,12 @@ namespace OpenSim.Region.CoreModules.World.Region return; } - int nextInterval = DoOneNotice(); + int nextInterval = DoOneNotice(true); SetTimer(nextInterval); } - public int DoOneNotice() + public int DoOneNotice(bool sendOut) { if (m_Alerts.Count == 0 || m_Alerts[0] == 0) { @@ -182,34 +184,37 @@ namespace OpenSim.Region.CoreModules.World.Region m_Alerts.RemoveAt(0); - int minutes = currentAlert / 60; - string currentAlertString = String.Empty; - if (minutes > 0) + if (sendOut) { - if (minutes == 1) - currentAlertString += "1 minute"; - else - currentAlertString += String.Format("{0} minutes", minutes); + int minutes = currentAlert / 60; + string currentAlertString = String.Empty; + if (minutes > 0) + { + if (minutes == 1) + currentAlertString += "1 minute"; + else + currentAlertString += String.Format("{0} minutes", minutes); + if ((currentAlert % 60) != 0) + currentAlertString += " and "; + } if ((currentAlert % 60) != 0) - currentAlertString += " and "; - } - if ((currentAlert % 60) != 0) - { - int seconds = currentAlert % 60; - if (seconds == 1) - currentAlertString += "1 second"; - else - currentAlertString += String.Format("{0} seconds", seconds); - } + { + int seconds = currentAlert % 60; + if (seconds == 1) + currentAlertString += "1 second"; + else + currentAlertString += String.Format("{0} seconds", seconds); + } - string msg = String.Format(m_Message, currentAlertString); + string msg = String.Format(m_Message, currentAlertString); - if (m_DialogModule != null && msg != String.Empty) - { - if (m_Notice) - m_DialogModule.SendGeneralAlert(msg); - else - m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); + if (m_DialogModule != null && msg != String.Empty) + { + if (m_Notice) + m_DialogModule.SendGeneralAlert(msg); + else + m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg); + } } return currentAlert - nextAlert; @@ -226,7 +231,25 @@ namespace OpenSim.Region.CoreModules.World.Region private void OnTimer(object source, ElapsedEventArgs e) { - int nextInterval = DoOneNotice(); + int nextInterval = DoOneNotice(true); + + SetTimer(nextInterval); + } + + public void DelayRestart(int seconds, string message) + { + if (m_CountdownTimer == null) + return; + + m_CountdownTimer.Stop(); + m_CountdownTimer = null; + + m_Alerts = new List(m_CurrentAlerts); + m_Alerts.Add(seconds); + m_Alerts.Sort(); + m_Alerts.Reverse(); + + int nextInterval = DoOneNotice(false); SetTimer(nextInterval); } @@ -240,9 +263,9 @@ namespace OpenSim.Region.CoreModules.World.Region if (m_DialogModule != null && message != String.Empty) m_DialogModule.SendGeneralAlert(message); } - if (m_MarkerPath != String.Empty) - File.Delete(Path.Combine(m_MarkerPath, - m_Scene.RegionInfo.RegionID.ToString())); + if (m_MarkerPath != String.Empty) + File.Delete(Path.Combine(m_MarkerPath, + m_Scene.RegionInfo.RegionID.ToString())); } private void HandleRegionRestart(string module, string[] args) diff --git a/OpenSim/Region/Framework/Interfaces/IRestartModule.cs b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs index c68550f393..9b25bebd1c 100644 --- a/OpenSim/Region/Framework/Interfaces/IRestartModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs @@ -35,5 +35,6 @@ namespace OpenSim.Region.Framework.Interfaces TimeSpan TimeUntilRestart { get; } void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice); void AbortRestart(string message); + void DelayRestart(int seconds, string message); } }