Allow short-circuiting region restart delays of there are no users left

melanie
Melanie Thielker 2017-03-23 23:00:14 +00:00
parent 4e465002a2
commit 3e880cee45
1 changed files with 43 additions and 0 deletions

View File

@ -61,6 +61,8 @@ namespace OpenSim.Region.CoreModules.World.Region
protected IDialogModule m_DialogModule = null; protected IDialogModule m_DialogModule = null;
protected string m_MarkerPath = String.Empty; protected string m_MarkerPath = String.Empty;
private int[] m_CurrentAlerts = null; private int[] m_CurrentAlerts = null;
protected bool m_shortCircuitDelays = false;
protected bool m_rebootAll = false;
public void Initialise(IConfigSource config) public void Initialise(IConfigSource config)
{ {
@ -69,6 +71,9 @@ namespace OpenSim.Region.CoreModules.World.Region
{ {
m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty);
} }
IConfig startupConfig = config.Configs["Startup"];
m_shortCircuitDelays = startupConfig.GetBoolean("SkipDelayOnEmptyRegion", false);
m_rebootAll = startupConfig.GetBoolean("InworldRestartShutsDown", false);
} }
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
@ -250,6 +255,14 @@ namespace OpenSim.Region.CoreModules.World.Region
private void OnTimer(object source, ElapsedEventArgs e) private void OnTimer(object source, ElapsedEventArgs e)
{ {
int nextInterval = DoOneNotice(true); int nextInterval = DoOneNotice(true);
if (m_shortCircuitDelays)
{
if (CountAgents() == 0)
{
m_Scene.RestartNow();
return;
}
}
SetTimer(nextInterval); SetTimer(nextInterval);
} }
@ -349,5 +362,35 @@ namespace OpenSim.Region.CoreModules.World.Region
{ {
} }
} }
int CountAgents()
{
m_log.Info("[RESTART MODULE]: Counting affected avatars");
int agents = 0;
if (m_rebootAll)
{
foreach (Scene s in SceneManager.Instance.Scenes)
{
foreach (ScenePresence sp in s.GetScenePresences())
{
if (!sp.IsChildAgent)
agents++;
}
}
}
else
{
foreach (ScenePresence sp in m_Scene.GetScenePresences())
{
if (!sp.IsChildAgent)
agents++;
}
}
m_log.InfoFormat("[RESTART MODULE]: Avatars in region: {0}", agents);
return agents;
}
} }
} }