From e586a6cc8f22c9a152f2faef2cdee9565cf78f41 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 23 Nov 2019 10:40:02 +0700 Subject: [PATCH] reset the loss detection timer when dropping a packet number space --- internal/ackhandler/sent_packet_handler.go | 2 ++ .../ackhandler/sent_packet_handler_test.go | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index 3bbee31fe..555be19d6 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -120,6 +120,8 @@ func (h *sentPacketHandler) DropPackets(encLevel protocol.EncryptionLevel) { default: panic(fmt.Sprintf("Cannot drop keys for encryption level %s", encLevel)) } + h.setLossDetectionTimer() + h.ptoMode = SendNone } func (h *sentPacketHandler) SentPacket(packet *Packet) { diff --git a/internal/ackhandler/sent_packet_handler_test.go b/internal/ackhandler/sent_packet_handler_test.go index 772f0c148..184cc6ad5 100644 --- a/internal/ackhandler/sent_packet_handler_test.go +++ b/internal/ackhandler/sent_packet_handler_test.go @@ -590,6 +590,28 @@ var _ = Describe("SentPacketHandler", func() { Expect(handler.GetLossDetectionTimeout().Sub(sendTime)).To(Equal(4 * timeout)) }) + It("resets the PTO mode when a packet number space is dropped", func() { + now := time.Now() + handler.SentPacket(ackElicitingPacket(&Packet{ + PacketNumber: 1, + EncryptionLevel: protocol.EncryptionHandshake, + SendTime: now.Add(-2 * time.Hour), + })) + handler.SentPacket(ackElicitingPacket(&Packet{ + PacketNumber: 2, + SendTime: now.Add(-time.Hour), + })) + // PTO timer based on the Handshake packet + Expect(handler.GetLossDetectionTimeout()).To(BeTemporally("~", now.Add(-2*time.Hour), time.Second)) + Expect(handler.OnLossDetectionTimeout()).To(Succeed()) + Expect(handler.SendMode()).To(Equal(SendPTOHandshake)) + handler.SetHandshakeComplete() + handler.DropPackets(protocol.EncryptionHandshake) + // PTO timer based on the 1-RTT packet + Expect(handler.GetLossDetectionTimeout()).To(BeTemporally("~", now.Add(-time.Hour), time.Second)) + Expect(handler.SendMode()).ToNot(Equal(SendPTOHandshake)) + }) + It("allows two 1-RTT PTOs", func() { handler.SetHandshakeComplete() var lostPackets []protocol.PacketNumber