Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cancel the PTO timer when all Handshake packets are acknowledged #3231

Merged
merged 1 commit into from Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/ackhandler/sent_packet_handler.go
Expand Up @@ -536,6 +536,13 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
// PTO alarm
ptoTime, encLevel, ok := h.getPTOTimeAndSpace()
if !ok {
if !oldAlarm.IsZero() {
h.alarm = time.Time{}
h.logger.Debugf("Canceling loss detection timer. No PTO needed..")
if h.tracer != nil {
h.tracer.LossTimerCanceled()
}
}
return
}
h.alarm = ptoTime
Expand Down
11 changes: 11 additions & 0 deletions internal/ackhandler/sent_packet_handler_test.go
Expand Up @@ -931,6 +931,17 @@ var _ = Describe("SentPacketHandler", func() {
handler.ReceivedPacket(protocol.EncryptionHandshake)
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
})

It("cancels the loss detection alarm when all Handshake packets are acknowledged", func() {
t := time.Now().Add(-time.Second)
handler.ReceivedBytes(99999)
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2, SendTime: t}))
handler.SentPacket(handshakePacket(&Packet{PacketNumber: 3, SendTime: t}))
handler.SentPacket(handshakePacket(&Packet{PacketNumber: 4, SendTime: t}))
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
handler.ReceivedAck(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 3, Largest: 4}}}, protocol.EncryptionHandshake, time.Now())
Expect(handler.GetLossDetectionTimeout()).To(BeZero())
})
})

Context("amplification limit, for the client", func() {
Expand Down