put back the packet buffer when parsing the connection ID fails

This commit is contained in:
Marten Seemann 2020-08-10 09:40:53 +07:00
parent d7c2169c55
commit 87f53228e9
2 changed files with 2 additions and 1 deletions

View file

@ -273,6 +273,7 @@ func (h *packetHandlerMap) handlePacket(
) {
connID, err := wire.ParseConnectionID(data, h.connIDLen)
if err != nil {
buffer.MaybeRelease()
h.logger.Debugf("error parsing connection ID on packet from %s: %s", addr, err)
if h.tracer != nil {
h.tracer.DroppedPacket(addr, logging.PacketTypeNotDetermined, protocol.ByteCount(len(data)), logging.PacketDropHeaderParseError)

View file

@ -130,7 +130,7 @@ var _ = Describe("Packet Handler Map", func() {
It("drops unparseable packets", func() {
addr := &net.UDPAddr{IP: net.IPv4(9, 8, 7, 6), Port: 1234}
tracer.EXPECT().DroppedPacket(addr, logging.PacketTypeNotDetermined, protocol.ByteCount(4), logging.PacketDropHeaderParseError)
handler.handlePacket(addr, nil, []byte{0, 1, 2, 3})
handler.handlePacket(addr, getPacketBuffer(), []byte{0, 1, 2, 3})
})
It("deletes removed sessions immediately", func() {