fix lowestInreceivedTimes index in new ReceivedPacketHandler

This commit is contained in:
Marten Seemann 2016-08-03 13:09:52 +07:00
parent 336fe548d7
commit 0c873d69ec
2 changed files with 6 additions and 1 deletions

View file

@ -135,5 +135,7 @@ func (h *receivedPacketHandler) garbageCollectReceivedTimes() {
for i := h.lowestInReceivedTimes; i <= h.ignorePacketsBelow; i++ {
delete(h.receivedTimes, i)
}
h.lowestInReceivedTimes = h.ignorePacketsBelow
if h.ignorePacketsBelow > h.lowestInReceivedTimes {
h.lowestInReceivedTimes = h.ignorePacketsBelow + 1
}
}

View file

@ -278,6 +278,7 @@ var _ = Describe("receivedPacketHandler", func() {
Expect(handler.receivedTimes).ToNot(HaveKey(protocol.PacketNumber(2)))
Expect(handler.receivedTimes).To(HaveKey(protocol.PacketNumber(3)))
Expect(handler.receivedTimes).To(HaveKey(protocol.PacketNumber(4)))
Expect(handler.lowestInReceivedTimes).To(Equal(protocol.PacketNumber(3)))
})
It("garbage collects the receivedTimes after receiving multiple StopWaitings", func() {
@ -292,6 +293,7 @@ var _ = Describe("receivedPacketHandler", func() {
Expect(handler.receivedTimes).To(HaveLen(2)) // packets 8 and 9
Expect(handler.receivedTimes).To(HaveKey(protocol.PacketNumber(8)))
Expect(handler.receivedTimes).To(HaveKey(protocol.PacketNumber(9)))
Expect(handler.lowestInReceivedTimes).To(Equal(protocol.PacketNumber(8)))
})
It("garbage collects receivedTimes after receiving a StopWaiting, if there are missing packets", func() {
@ -306,6 +308,7 @@ var _ = Describe("receivedPacketHandler", func() {
Expect(handler.receivedTimes).ToNot(HaveKey(protocol.PacketNumber(1)))
Expect(handler.receivedTimes).ToNot(HaveKey(protocol.PacketNumber(2)))
Expect(handler.receivedTimes).To(HaveKey(protocol.PacketNumber(4)))
Expect(handler.lowestInReceivedTimes).To(Equal(protocol.PacketNumber(4)))
})
})
})