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.
avinationmerge
Melanie 2012-06-07 16:32:07 +02:00
parent a945105003
commit e93308072e
3 changed files with 61 additions and 31 deletions

View File

@ -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;
}

View File

@ -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<int>(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<int>(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)

View File

@ -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);
}
}