From d4905812bc07efb819230d472beb2d75d91bb046 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Thu, 21 Feb 2008 20:22:25 +0000
Subject: * Fixed an issue where the client thread was aborted before the UDP
 server sends a message back to ClientView to close it a second time.   (yes
 we call close twice because there are times when the client closes with a
 logout and disconnects immediately which causes the UDP server to send a
 close request to the client thread) * This update might make things better,
 it might expose another issue.

---
 OpenSim/Region/ClientStack/ClientView.cs | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 848a08d..1440d6c 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -238,7 +238,7 @@ namespace OpenSim.Region.ClientStack
 
         # region Client Methods
 
-        private void CloseCleanup()
+        private void CloseCleanup(bool ShutdownCircult)
         {
             m_scene.RemoveClient(AgentId);
 
@@ -268,8 +268,15 @@ namespace OpenSim.Region.ClientStack
             // We can't reach into other scenes and close the connection 
             // We need to do this over grid communications
             //m_scene.CloseAllAgents(CircuitCode);
-            GC.Collect();
-            m_clientThread.Abort();
+            
+            // If we're not shutting down the circuit, then this is the last time we'll go here.
+            // If we are shutting down the circuit, the UDP Server will come back here with 
+            // ShutDownCircuit = false
+            if (!(ShutdownCircult))
+            {
+                GC.Collect();
+                m_clientThread.Abort();
+            }
         }
 
         /// <summary>
@@ -286,7 +293,7 @@ namespace OpenSim.Region.ClientStack
             if (ShutdownCircult)
                 OnConnectionClosed(this);
 
-            CloseCleanup();
+            CloseCleanup(ShutdownCircult);
         }
 
         public void Kick(string message)
-- 
cgit v1.1