zero decode using a buffer from the pool

0.9.1.0-post-fixes
UbitUmarov 2019-02-25 23:30:01 +00:00
parent 91fab70236
commit d5d4dc4754
1 changed files with 14 additions and 6 deletions

View File

@ -1185,15 +1185,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try try
{ {
packet = Packet.BuildPacket(buffer.Data, ref packetEnd, // get a buffer for zero decode using the udp buffers pool
// Only allocate a buffer for zerodecoding if the packet is zerocoded UDPPacketBuffer zerodecodebufferholder = null;
((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : 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 // 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 // assume that packet construction does not retain a reference to byte[] buffer.Data (instead, all
// bytes are copied out). // bytes are copied out).
// packet = PacketPool.Instance.GetPacket(buffer.Data, ref packetEnd, // packet = PacketPool.Instance.GetPacket(buffer.Data, ref packetEnd, zerodecodebuffer);
// Only allocate a buffer for zerodecoding if the packet is zerocoded if(zerodecodebufferholder != null)
// ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null); FreeUDPBuffer(zerodecodebufferholder);
} }
catch (Exception e) catch (Exception e)
{ {