From 8c7149063bce41cac6543757c7b917583f21ea90 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Jun 2012 01:23:40 +0100 Subject: In PresenceDetector.OnConnectionClose(), use the IsChildAgent check already available on IClientAPI.SceneAgent rather than retrieving it again by scanning all scenes. --- OpenSim/Framework/IClientAPI.cs | 22 ++++++++++++++++------ .../Region/ClientStack/Linden/UDP/LLClientView.cs | 4 ++-- .../Presence/PresenceDetector.cs | 13 +------------ OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++---- 4 files changed, 22 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 869b069..f8b6a84 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -740,14 +740,24 @@ namespace OpenSim.Framework /// string Name { get; } - /// - /// Determines whether the client thread is doing anything or not. - /// + /// + /// True if the client is active (sending and receiving new UDP messages). False if the client is closing. + /// bool IsActive { get; set; } - /// - /// Determines whether the client is or has been removed from a given scene - /// + /// + /// Set if the client is closing due to a logout request or because of too much time since last ack. + /// + /// + /// Do not use this flag if you want to know if the client is closing, since it will not be set in other + /// circumstances (e.g. if a child agent is closed or the agent is kicked off the simulator). Use IsActive + /// instead. + /// + /// Only set for root agents. + /// + /// TODO: Too much time since last ack should probably be a separate property, or possibly part of a state + /// machine. + /// bool IsLoggingOut { get; set; } bool SendLogoutPacketWhenClosing { set; } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 74b9c6d..c4f167e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -490,12 +490,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void Close() { + IsActive = false; + m_log.DebugFormat( "[CLIENT]: Close has been called for {0} attached to scene {1}", Name, m_scene.RegionInfo.RegionName); - IsActive = false; - // Shutdown the image manager ImageManager.Close(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index ccfbf78..b43745c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -64,7 +64,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence scene.EventManager.OnNewClient -= OnNewClient; m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); - } public void OnMakeRootAgent(ScenePresence sp) @@ -80,18 +79,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnConnectionClose(IClientAPI client) { - if (client.IsLoggingOut) + if (client.IsLoggingOut && !client.SceneAgent.IsChildAgent) { - object sp = null; - if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) - { - if (sp is ScenePresence) - { - if (((ScenePresence)sp).IsChildAgent) - return; - } - } - // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_PresenceService.LogoutAgent(client.SessionId); } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7afde38..1305d83 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3463,10 +3463,9 @@ namespace OpenSim.Region.Framework.Scenes // Or the same user is trying to be root twice here, won't work. // Kill it. m_log.DebugFormat( - "[SCENE]: Zombie scene presence detected for {0} in {1}", - agent.AgentID, - RegionInfo.RegionName - ); + "[SCENE]: Zombie scene presence detected for {0} {1} in {2}", + sp.Name, sp.UUID, RegionInfo.RegionName); + sp.ControllingClient.Close(); sp = null; } -- cgit v1.1