From d5d4dc475461f889194a84aa682fbd555aad303f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 25 Feb 2019 23:30:01 +0000 Subject: [PATCH] zero decode using a buffer from the pool --- .../ClientStack/Linden/UDP/LLUDPServer.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 4739ae8e42..e931f3b884 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1185,15 +1185,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP try { - packet = Packet.BuildPacket(buffer.Data, ref packetEnd, - // Only allocate a buffer for zerodecoding if the packet is zerocoded - ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null); + // get a buffer for zero decode using the udp buffers pool + UDPPacketBuffer zerodecodebufferholder = null; + byte[] zerodecodebuffer = null; + // only if needed + if (((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0)) + { + zerodecodebufferholder = GetNewUDPBuffer(null); + zerodecodebuffer = zerodecodebufferholder.Data; + } + + 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, - // Only allocate a buffer for zerodecoding if the packet is zerocoded -// ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null); + // packet = PacketPool.Instance.GetPacket(buffer.Data, ref packetEnd, zerodecodebuffer); + if(zerodecodebufferholder != null) + FreeUDPBuffer(zerodecodebufferholder); } catch (Exception e) {