From 908e0e1cef792456fc1ba6394ff9119110870dc4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 13 Sep 2014 20:37:20 +0100 Subject: do not use a blind expire of m_pendingCache. Entries must be valid while respective HandleUseCircuitCode, no matter how long it takes, so a viewer retry doesnt start a overlapping one. It HandleUseCircuitCode responsability to always remove entries, even on fails. Remove a client even if m_scene.CloseAgent fails. --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 5ce82a5..18d5606 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -308,8 +308,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP - private ExpiringCache> m_pendingCache = new ExpiringCache>(); - +// private ExpiringCache> m_pendingCache = new ExpiringCache>(); + private Dictionary> m_pendingCache = new Dictionary>(); /// /// Event used to signal when queued packets are available for sending. /// @@ -1416,10 +1416,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP // And if there is a UseCircuitCode pending, also drop it lock (m_pendingCache) { - if (m_pendingCache.Contains(endPoint)) +// if (m_pendingCache.Contains(endPoint)) + if (m_pendingCache.ContainsKey(endPoint)) return; - m_pendingCache.AddOrUpdate(endPoint, new Queue(), 60); +// m_pendingCache.AddOrUpdate(endPoint, new Queue(), 60); + m_pendingCache.Add(endPoint, new Queue()); } // We need to copy the endpoint so that it doesn't get changed when another thread reuses the @@ -1765,10 +1767,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP uccp.CircuitCode.SessionID, endPoint, sessionInfo); - - // Now we know we can handle more data - Thread.Sleep(200); - + // Obtain the pending queue and remove it from the cache Queue queue = null; @@ -1786,13 +1785,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count); // Reinject queued packets - while (queue.Count > 0) + if (queue != null) { - UDPPacketBuffer buf = queue.Dequeue(); - PacketReceived(buf); - } + while (queue.Count > 0) + { + UDPPacketBuffer buf = queue.Dequeue(); + PacketReceived(buf); + } - queue = null; + queue = null; + } // Send ack straight away to let the viewer know that the connection is active. // The client will be null if it already exists (e.g. if on a region crossing the client sends a use @@ -1815,6 +1817,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.WarnFormat( "[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}", uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint); + lock (m_pendingCache) m_pendingCache.Remove(endPoint); } @@ -1825,6 +1828,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP } catch (Exception e) { + // this may already be done.. or not.. + lock (m_pendingCache) + m_pendingCache.Remove(endPoint); + m_log.ErrorFormat( "[LLUDPSERVER]: UseCircuitCode handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}", endPoint != null ? endPoint.ToString() : "n/a", @@ -2058,11 +2065,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP "[LLUDPSERVER]: No packets received from {0} agent of {1} for {2}ms in {3}. Disconnecting.", client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, timeoutTicks, m_scene.Name); - if (!client.SceneAgent.IsChildAgent) + if (client.SceneAgent != null && !client.SceneAgent.IsChildAgent) client.Kick("Simulator logged you out due to connection timeout."); } - m_scene.CloseAgent(client.AgentId, true); + if (!m_scene.CloseAgent(client.AgentId, true)) + client.Close(true,true); } private void IncomingPacketHandler() -- cgit v1.1