correct the bytes in flight when dropping crypto packets

This commit is contained in:
Marten Seemann
2019-05-30 01:47:03 +08:00
parent 5009f1cb19
commit ea33339d26
2 changed files with 5 additions and 0 deletions

View File

@@ -114,6 +114,9 @@ func (h *sentPacketHandler) SetHandshakeComplete() {
for _, pnSpace := range []*packetNumberSpace{h.initialPackets, h.handshakePackets} {
var cryptoPackets []*Packet
pnSpace.history.Iterate(func(p *Packet) (bool, error) {
if p.includedInBytesInFlight {
h.bytesInFlight -= p.Length
}
cryptoPackets = append(cryptoPackets, p)
return true, nil
})

View File

@@ -860,11 +860,13 @@ var _ = Describe("SentPacketHandler", func() {
p := ackElicitingPacket(&Packet{PacketNumber: i, EncryptionLevel: protocol.EncryptionHandshake})
handler.SentPacket(p)
}
Expect(handler.bytesInFlight).ToNot(BeZero())
handler.queuePacketForRetransmission(getPacket(1, protocol.EncryptionInitial), handler.getPacketNumberSpace(protocol.EncryptionInitial))
handler.queuePacketForRetransmission(getPacket(3, protocol.EncryptionHandshake), handler.getPacketNumberSpace(protocol.EncryptionHandshake))
handler.SetHandshakeComplete()
Expect(handler.initialPackets.history.Len()).To(BeZero())
Expect(handler.handshakePackets.history.Len()).To(BeZero())
Expect(handler.bytesInFlight).To(BeZero())
packet := handler.DequeuePacketForRetransmission()
Expect(packet).To(BeNil())
})