lludp remove obsolete pending queue

This commit is contained in:
UbitUmarov
2021-06-02 14:28:47 +01:00
parent a473cbe128
commit 21da22b6ec
6 changed files with 25 additions and 82 deletions

View File

@@ -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)

View File

@@ -326,7 +326,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary>Flag to signal when clients should send pings</summary>
protected bool m_sendPing;
protected ExpiringCacheOS<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCacheOS<IPEndPoint, Queue<UDPPacketBuffer>>(10000);
protected readonly ExpiringKey<IPEndPoint> m_pendingEndpointHandleCircuit = new ExpiringKey<IPEndPoint>(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<UDPPacketBuffer>(), 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<UDPPacketBuffer> 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<UDPPacketBuffer> 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);
}
}
/// <summary>