From e3db5fb6037e52596648cf9860f336b82df2919a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 19 Jul 2012 00:09:22 +0100 Subject: [PATCH] Add EventManager.OnRegionLoginsStatusChange fired whenever logins are enabled or disabled at any point, not just during initial startup. This replaces EventManager.OnLoginsEnabled which only fired when logins were first enabled and was affected by a bug where it would never fire if the region started with logins disabled. --- OpenSim/Framework/IScene.cs | 5 +++++ .../CoreModules/World/Access/AccessModule.cs | 10 ++++----- .../Region/Framework/Scenes/EventManager.cs | 21 ++++++++++--------- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++----- OpenSim/Region/Framework/Scenes/SceneBase.cs | 18 ++++++++++++++++ .../Tests/ScenePresenceTeleportTests.cs | 2 +- .../RegionReadyModule/RegionReadyModule.cs | 4 +--- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +- 8 files changed, 47 insertions(+), 25 deletions(-) diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index a9432c2df3..2c38e0f6a1 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -66,6 +66,11 @@ namespace OpenSim.Framework IConfigSource Config { get; } + /// + /// Are logins enabled on this simulator? + /// + bool LoginsEnabled { get; set; } + float TimeDilation { get; } bool AllowScriptCrossings { get; } diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index 553a32d3bd..e7b14547f4 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs @@ -129,18 +129,18 @@ namespace OpenSim.Region.CoreModules.World switch (cmd[1]) { case "enable": - scene.LoginsDisabled = false; + scene.LoginsEnabled = true; MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); break; case "disable": - scene.LoginsDisabled = true; + scene.LoginsEnabled = false; MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); break; case "status": - if (scene.LoginsDisabled) - MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName)); - else + if (scene.LoginsEnabled) MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName)); + else + MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName)); break; default: MainConsole.Instance.Output("Syntax: login enable|disable|status"); diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index e7a1e3cf51..f2f2db8c1c 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -490,13 +490,14 @@ namespace OpenSim.Region.Framework.Scenes public event RegionHeartbeatEnd OnRegionHeartbeatEnd; /// - /// This should only fire in all circumstances if the RegionReady module is active. + /// Fired when logins to a region are enabled or disabled. /// /// - /// TODO: Fire this even when the RegionReady module is not active. + /// /// - public delegate void LoginsEnabled(IScene scene); - public event LoginsEnabled OnLoginsEnabled; + /// Fired + public event RegionLoginsStatusChange OnRegionLoginsStatusChange; + public delegate void RegionLoginsStatusChange(IScene scene); /// /// Fired when a region is considered ready for use. @@ -505,8 +506,8 @@ namespace OpenSim.Region.Framework.Scenes /// A region is considered ready when startup operations such as loading of scripts already on the region /// have been completed. /// - public delegate void RegionReady(IScene scene); public event RegionReady OnRegionReady; + public delegate void RegionReady(IScene scene); public delegate void PrimsLoaded(Scene s); public event PrimsLoaded OnPrimsLoaded; @@ -2437,13 +2438,13 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerLoginsEnabled(IScene scene) + public void TriggerRegionLoginsStatusChange(IScene scene) { - LoginsEnabled handler = OnLoginsEnabled; + RegionLoginsStatusChange handler = OnRegionLoginsStatusChange; if (handler != null) { - foreach (LoginsEnabled d in handler.GetInvocationList()) + foreach (RegionLoginsStatusChange d in handler.GetInvocationList()) { try { @@ -2451,13 +2452,13 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnLoginsEnabled failed - continuing {0} - {1}", + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionLoginsStatusChange failed - continuing {0} - {1}", e.Message, e.StackTrace); } } } } - + public void TriggerRegionReady(IScene scene) { RegionReady handler = OnRegionReady; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9190591451..95fb9a7b61 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -124,9 +124,10 @@ namespace OpenSim.Region.Framework.Scenes // root agents when ACL denies access to root agent public bool m_strictAccessControl = true; public int MaxUndoCount = 5; + // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; public bool LoginLock = false; - public bool LoginsDisabled = true; + public bool StartDisabled = false; public bool LoadingPrims; public IXfer XferManager; @@ -1436,7 +1437,7 @@ namespace OpenSim.Region.Framework.Scenes // landMS = Util.EnvironmentTickCountSubtract(ldMS); //} - if (LoginsDisabled && Frame == 20) + if (!LoginsEnabled && Frame == 20) { // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); @@ -1450,8 +1451,7 @@ namespace OpenSim.Region.Framework.Scenes if (!StartDisabled) { m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); - LoginsDisabled = false; - EventManager.TriggerLoginsEnabled(this); + LoginsEnabled = true; } m_sceneGridService.InformNeighborsThatRegionisUp( @@ -3413,7 +3413,7 @@ namespace OpenSim.Region.Framework.Scenes RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); - if (LoginsDisabled) + if (!LoginsEnabled) { reason = "Logins Disabled"; return false; diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index f50fbfcdbf..282fc5e927 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -106,6 +106,24 @@ namespace OpenSim.Region.Framework.Scenes protected readonly ClientManager m_clientManager = new ClientManager(); + public bool LoginsEnabled + { + get + { + return m_loginsEnabled; + } + + set + { + if (m_loginsEnabled != value) + { + m_loginsEnabled = value; + EventManager.TriggerRegionLoginsStatusChange(this); + } + } + } + private bool m_loginsEnabled; + public float TimeDilation { get { return 1.0f; } diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index a407f01d63..37b5184715 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -301,7 +301,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests sp.AbsolutePosition = preTeleportPosition; // Make sceneB refuse CreateAgent - sceneB.LoginsDisabled = true; + sceneB.LoginsEnabled = false; sceneA.RequestTeleportLocation( sp.ControllingClient, diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index cb09672527..4489bd7712 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -215,15 +215,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady if (!m_scene.StartDisabled) { - m_scene.LoginsDisabled = false; + m_scene.LoginsEnabled = true; // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); m_log.InfoFormat( "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); - - m_scene.EventManager.TriggerLoginsEnabled(m_scene); } m_scene.SceneGridService.InformNeighborsThatRegionisUp( diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 769de83c9c..7598cc360e 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -190,7 +190,7 @@ namespace OpenSim.Tests.Common = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); testScene.RegionInfo.EstateSettings = new EstateSettings(); - testScene.LoginsDisabled = false; + testScene.LoginsEnabled = true; testScene.RegisterRegionWithGrid(); SceneManager.Add(testScene);