From e3fa73da96f5612da52d140425f1633494d6edef Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 17:17:59 +0200 Subject: Experimentally handle UseCircuitCode synchrnonously --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index bd8273d..56c0992 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -701,7 +701,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { object[] array = new object[] { buffer, packet }; - Util.FireAndForget(HandleUseCircuitCode, array); + //Util.FireAndForget(HandleUseCircuitCode, array); + HandleUseCircuitCode(array); return; } -- cgit v1.1 From 8b4f7604e618ed409cd4dcb44dcf14ce22b72be7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 19:45:08 +0200 Subject: Revert "Experimentally handle UseCircuitCode synchrnonously" This reverts commit e3fa73da96f5612da52d140425f1633494d6edef. --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 56c0992..bd8273d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -701,8 +701,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { object[] array = new object[] { buffer, packet }; - //Util.FireAndForget(HandleUseCircuitCode, array); - HandleUseCircuitCode(array); + Util.FireAndForget(HandleUseCircuitCode, array); return; } -- cgit v1.1 From 283df0610de50f77460f980ba15e4cbb23f5b657 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 21:45:06 +0200 Subject: Save packets received while the client is added and replay them later. --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index bd8273d..34923be 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -153,6 +153,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Flag to signal when clients should send pings private bool m_sendPing; + private ExpiringCache> m_pendingCache = new ExpiringCache>(); + private int m_defaultRTO = 0; private int m_maxRTO = 0; @@ -701,6 +703,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { object[] array = new object[] { buffer, packet }; + lock (m_pendingCache) + m_pendingCache.AddOrUpdate(address, new Queue(), 60); Util.FireAndForget(HandleUseCircuitCode, array); return; @@ -710,6 +714,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP IClientAPI client; if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) { + lock (m_pendingCache) + { + Queue queue; + if (m_pendingCache.TryGetValue(address, out queue)) + queue.Enqueue(buffer); + } + // m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); return; } @@ -943,6 +954,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP // We only want to send initial data to new clients, not ones which are being converted from child to root. if (client != null) client.SceneAgent.SendInitialDataToMe(); + + // Now we know we can handle more data + Thread.Sleep(200); + + // Obtain the queue and remove it from the cache + Queue queue = null; + + lock (m_pendingCache) + { + if (!m_pendingCache.TryGetValue(remoteEndPoint, out queue)) + return; + m_pendingCache.Remove(remoteEndPoint); + } + + // Reinject queued packets + while(queue.Count > 0) + { + UDPPacketBuffer buf = queue.Dequeue(); + PacketReceived(buf); + } + queue = null; } else { @@ -950,6 +982,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.WarnFormat( "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", uccp.CircuitCode.ID, uccp.CircuitCode.Code, remoteEndPoint); + lock (m_pendingCache) + m_pendingCache.Remove(remoteEndPoint); } // m_log.DebugFormat( -- cgit v1.1 From b130dcea21130b65a3dbe400b0c50e1f5e461972 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 22:28:47 +0200 Subject: Testing changes and instrumentation --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 34923be..c807260 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -701,10 +701,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP // UseCircuitCode handling if (packet.Type == PacketType.UseCircuitCode) { - object[] array = new object[] { buffer, packet }; - lock (m_pendingCache) + { + if (m_pendingCache.Contains(address)) + return; + m_pendingCache.AddOrUpdate(address, new Queue(), 60); + } + + object[] array = new object[] { buffer, packet }; + Util.FireAndForget(HandleUseCircuitCode, array); return; @@ -718,10 +724,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP { Queue queue; if (m_pendingCache.TryGetValue(address, out queue)) + { + m_log.DebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type); queue.Enqueue(buffer); + } + else + { + m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); + } } -// m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); return; } @@ -964,10 +976,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP lock (m_pendingCache) { if (!m_pendingCache.TryGetValue(remoteEndPoint, out queue)) + { + m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present"); return; + } m_pendingCache.Remove(remoteEndPoint); } + m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count); + // Reinject queued packets while(queue.Count > 0) { -- cgit v1.1 From 668723fab31976895ceb42a372cfff7ed5689a9d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 23:01:58 +0200 Subject: Remove instrumentation and fix the message delivery issue --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 52 ++++++++++++---------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index c807260..46337b3 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -698,42 +698,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Packet to Client Mapping - // UseCircuitCode handling - if (packet.Type == PacketType.UseCircuitCode) + // If there is already a client for this endpoint, don't process UseCircuitCode + IClientAPI client = null; + if (!m_scene.TryGetClient(address, out client)) { - lock (m_pendingCache) + // UseCircuitCode handling + if (packet.Type == PacketType.UseCircuitCode) { - if (m_pendingCache.Contains(address)) - return; + // And if there is a UseCircuitCode pending, also drop it + lock (m_pendingCache) + { + if (m_pendingCache.Contains(address)) + return; - m_pendingCache.AddOrUpdate(address, new Queue(), 60); - } + m_pendingCache.AddOrUpdate(address, new Queue(), 60); + } - object[] array = new object[] { buffer, packet }; + object[] array = new object[] { buffer, packet }; - Util.FireAndForget(HandleUseCircuitCode, array); + Util.FireAndForget(HandleUseCircuitCode, array); - return; + return; + } } - // Determine which agent this packet came from - IClientAPI client; - if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) + // If this is a pending connection, enqueue, don't process yet + lock (m_pendingCache) { - lock (m_pendingCache) + Queue queue; + if (m_pendingCache.TryGetValue(address, out queue)) { - Queue queue; - if (m_pendingCache.TryGetValue(address, out queue)) - { - m_log.DebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type); - queue.Enqueue(buffer); - } - else - { - m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); - } + //m_log.DebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type); + queue.Enqueue(buffer); + return; } + } + // Determine which agent this packet came from + if (client == null || !(client is LLClientView)) + { + //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); return; } -- cgit v1.1