From 21da22b6ecb837b454a1a5313dbb4fc3bb1ce038 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 2 Jun 2021 14:28:47 +0100 Subject: [PATCH] lludp remove obsolete pending queue --- OpenSim/Framework/AgentCircuitData.cs | 8 +- OpenSim/Framework/AgentCircuitManager.cs | 1 + OpenSim/Framework/ObjectJobEngine.cs | 3 +- .../ClientStack/Linden/UDP/LLClientView.cs | 8 -- .../ClientStack/Linden/UDP/LLUDPServer.cs | 85 +++++-------------- .../ubOdeMeshing/Meshmerizer.cs | 2 +- 6 files changed, 25 insertions(+), 82 deletions(-) diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index ebb00d2b1d..5c64839a3f 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -40,11 +40,7 @@ namespace OpenSim.Framework /// public class AgentCircuitData { -// DEBUG ON - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); -// DEBUG OFF + private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); /// /// Avatar Unique Agent Identifier @@ -275,7 +271,7 @@ namespace OpenSim.Framework if (args.TryGetValue("caps_path", out tmpOSD)) CapsPath = tmpOSD.AsString(); - if ((args.TryGetValue("children_seeds", out tmpOSD) && tmpOSD is OSDArray)) + if (args.TryGetValue("children_seeds", out tmpOSD) && tmpOSD is OSDArray) { OSDArray childrenSeeds = (OSDArray)tmpOSD; ChildrenCapSeeds = new Dictionary(); diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs index 466483f2bc..dea81a9c5d 100644 --- a/OpenSim/Framework/AgentCircuitManager.cs +++ b/OpenSim/Framework/AgentCircuitManager.cs @@ -88,6 +88,7 @@ namespace OpenSim.Framework /// public virtual void AddNewCircuit(AgentCircuitData agentData) { + agentData.child = true; RemoveCircuit(agentData.AgentID); // no duplications m_agentCircuits[agentData.circuitcode] = agentData; m_agentCircuitsByUUID[agentData.AgentID] = agentData; diff --git a/OpenSim/Framework/ObjectJobEngine.cs b/OpenSim/Framework/ObjectJobEngine.cs index 89a700f9a3..1087a25a32 100644 --- a/OpenSim/Framework/ObjectJobEngine.cs +++ b/OpenSim/Framework/ObjectJobEngine.cs @@ -178,8 +178,7 @@ namespace OpenSim.Framework } catch (Exception e) { - m_log.ErrorFormat( - "[ObjectJob {0}]: Job failed, continuing. Exception {1}",m_name, e); + m_log.ErrorFormat("[ObjectJob {0}]: Job failed, continuing. Exception {1}", m_name, e); } } lock (m_mainLock) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 630ea2f0e5..5a7e6c6f8d 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -8345,19 +8345,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void HandleAgentUpdate(Packet packet) { if(OnAgentUpdate == null) - { - //PacketPool.Instance.ReturnPacket(packet); return; - } AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; if (x.AgentID != AgentId || x.SessionID != SessionId) - { - //PacketPool.Instance.ReturnPacket(packet); return; - } uint seq = packet.Header.Sequence; @@ -8421,8 +8415,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if(movement && camera) m_thisAgentUpdateArgs.lastUpdateTS = now; - - //PacketPool.Instance.ReturnPacket(packet); } private void HandleMoneyTransferRequest(Packet Pack) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index a2bda1f643..c7f100ce6d 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -326,7 +326,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Flag to signal when clients should send pings protected bool m_sendPing; - protected ExpiringCacheOS> m_pendingCache = new ExpiringCacheOS>(10000); + protected readonly ExpiringKey m_pendingEndpointHandleCircuit = new ExpiringKey(10000); protected int m_defaultRTO = 0; protected int m_maxRTO = 0; @@ -440,7 +440,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP IConfig packetConfig = configSource.Configs["PacketPool"]; if (packetConfig != null) { - PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); + //PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); // PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); // usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools); } @@ -1275,10 +1275,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } packet = Packet.BuildPacket(buffer.Data, ref packetEnd, zerodecodebuffer); - // If OpenSimUDPBase.UsePool == true (which is currently separate from the PacketPool) then we - // assume that packet construction does not retain a reference to byte[] buffer.Data (instead, all - // bytes are copied out). - // packet = PacketPool.Instance.GetPacket(buffer.Data, ref packetEnd, zerodecodebuffer); if(zerodecodebufferholder != null) FreeUDPBuffer(zerodecodebufferholder); } @@ -1304,48 +1300,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Decoding + FreeUDPBuffer(buffer); + #region Packet to Client Mapping // usecircuitcode handling - if (!Scene.TryGetClient(endPoint, out IClientAPI client) || !(client is LLClientView)) + if (!Scene.TryGetClient(endPoint, out IClientAPI client)) { // UseCircuitCode handling if (packet.Type == PacketType.UseCircuitCode) { - // And if there is a UseCircuitCode pending, also drop it - - lock (m_pendingCache) + //flood control + if (m_pendingEndpointHandleCircuit.ContainsKey(endPoint)) { - if (m_pendingCache.Contains(endPoint)) - { - FreeUDPBuffer(buffer); - SendAckImmediate(endPoint, packet.Header.Sequence); // i hear you shutup - return; - } - - m_pendingCache.AddOrUpdate(endPoint, new Queue(), 60); + SendAckImmediate(endPoint, packet.Header.Sequence); // i hear you shutup + return; } - + m_pendingEndpointHandleCircuit.Add(endPoint, 120); Util.FireAndForget(HandleUseCircuitCode, new object[] { endPoint, packet }); - FreeUDPBuffer(buffer); - SendAckImmediate(endPoint, packet.Header.Sequence); return; } } - // If this is a pending connection, enqueue, don't process yet - lock (m_pendingCache) - { - if (m_pendingCache.TryGetValue(endPoint, out Queue queue)) - { - //m_log.DebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type); - queue.Enqueue(buffer); - return; - } - } - - FreeUDPBuffer(buffer); - // Determine which agent this packet came from if (client == null || !(client is LLClientView)) { @@ -1634,14 +1610,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP AgentCircuitData aCircuit = m_circuitManager.GetAgentCircuitData(uccp.CircuitCode.Code); // Begin the process of adding the client to the simulator - client - = AddClient( + client = AddClient( uccp.CircuitCode.Code, uccp.CircuitCode.ID, uccp.CircuitCode.SessionID, endPoint, sessionInfo); + SendAckImmediate(endPoint, uccp.Header.Sequence); // This will be true if the client is new, e.g. not // an existing child agent, and there is no circuit data if (client != null && aCircuit == null) @@ -1650,29 +1626,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; } - - // Obtain the pending queue and remove it from the cache - Queue queue = null; - lock (m_pendingCache) - { - if (!m_pendingCache.TryGetValue(endPoint, out queue)) - { - m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present"); - return; - } - m_pendingCache.Remove(endPoint); - } - - m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count); - // Reinject queued packets - while (queue.Count > 0) - { - UDPPacketBuffer buf = queue.Dequeue(); - PacketReceived(buf); - } - - queue = null; - if (client != null) { if(aCircuit.teleportFlags <= 0) @@ -1684,16 +1637,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Don't create clients for unauthorized requesters. m_log.WarnFormat( "[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}", - uccp.CircuitCode.ID, Scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint); - lock (m_pendingCache) - m_pendingCache.Remove(endPoint); + SendAckImmediate(endPoint, uccp.Header.Sequence); } - // m_log.DebugFormat( - // "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", - // buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); + //m_log.DebugFormat( + // "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", + // buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); } catch (Exception e) @@ -1706,6 +1657,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP e.Message, e.StackTrace); } + finally + { + m_pendingEndpointHandleCircuit?.Remove(endPoint); + } } /// diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs index 206a46ada3..328afb1b26 100644 --- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing public string cachePath = "MeshCache"; public TimeSpan CacheExpire; -// const string baseDir = "rawFiles"; + //private const string baseDir = "rawFiles"; private const string baseDir = null; //"rawFiles"; private bool useMeshiesPhysicsMesh = true;