From a453672edb8169f9957e136ee8252e7391170721 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 21 Dec 2007 16:55:03 +0000 Subject: * Remapped the Connection shutdown path. * This fixes a *bunch* of Mantis bugs related to the following * -- Neighbouring simulators not appearing after relog * -- Login to simulator only to be logged off by simulator. * -- ThreadAbort * -- Unable to shutdown circuitCode: x --- OpenSim/Region/ClientStack/ClientView.cs | 36 ++++++++++++++++------ OpenSim/Region/ClientStack/PacketServer.cs | 2 +- OpenSim/Region/Environment/Scenes/Scene.cs | 6 ++-- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 +- 4 files changed, 32 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 31e0e29..34186de 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -199,38 +199,56 @@ namespace OpenSim.Region.ClientStack # region Client Methods - public void Close() + private void CloseCleanup() { - // Pull Client out of Region - MainLog.Instance.Verbose("CLIENT", "Close has been called"); m_scene.RemoveClient(AgentId); - // Send the STOP packet DisableSimulatorPacket disable = new DisableSimulatorPacket(); OutPacket(disable, ThrottleOutPacketType.Task); + // FLUSH Packets m_packetQueue.Close(); m_packetQueue.Flush(); Thread.Sleep(2000); - + + + + + // Shut down timers m_ackTimer.Stop(); m_clientPingTimer.Stop(); - + // This is just to give the client a reasonable chance of // flushing out all it's packets. There should probably // be a better mechanism here - + // We can't reach into other scenes and close the connection // We need to do this over grid communications - m_scene.CloseAllAgents(CircuitCode); + //m_scene.CloseAllAgents(CircuitCode); m_clientThread.Abort(); } + public void Close(bool ShutdownCircult) + { + + // Pull Client out of Region + MainLog.Instance.Verbose("CLIENT", "Close has been called"); + + //raiseevent on the packet server to Shutdown the circuit + if (ShutdownCircult) + OnConnectionClosed(this); + + + CloseCleanup(); + + + } + public void Kick(string message) { KickUserPacket kupack = new KickUserPacket(); @@ -2214,7 +2232,7 @@ namespace OpenSim.Region.ClientStack "ClientView.m_packetQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + m_userEndPoint.ToString() + " - killing thread"); MainLog.Instance.Error(e.ToString()); - Close(); + Close(true); } } diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 308728e..a4c18d0 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -132,7 +132,7 @@ namespace OpenSim.Region.ClientStack public virtual void CloseClient(IClientAPI client) { CloseCircuit(client.CircuitCode); - client.Close(); + client.Close(false); } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 0cb353c..c4b409f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -478,7 +478,7 @@ namespace OpenSim.Region.Environment.Scenes // Stop all client threads. ForEachScenePresence(delegate(ScenePresence avatar) { - avatar.ControllingClient.Close(); + avatar.ControllingClient.Close(true); }); // Stop updating the scene objects and agents. m_heartbeatTimer.Close(); @@ -1758,7 +1758,7 @@ namespace OpenSim.Region.Environment.Scenes bool childagent = !p.Equals(null) && p.IsChildAgent; if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Close(); + controller.Close(true); } } ); @@ -1775,7 +1775,7 @@ namespace OpenSim.Region.Environment.Scenes } m_scenePresences[agentID].ControllingClient.Kick(Helpers.FieldToUTF8String(reason)); - m_scenePresences[agentID].ControllingClient.Close(); + m_scenePresences[agentID].ControllingClient.Close(true); } } else diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index a59e7d6..4722c13 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -464,7 +464,7 @@ namespace SimpleApp { } - public void Close() + public void Close(bool ShutdownCircuit) { } -- cgit v1.1