don't send the same StopWaitingFrame twice

fixes #229
This commit is contained in:
Marten Seemann
2016-07-30 14:15:45 +07:00
parent b7d2a76811
commit 71243ccccb
4 changed files with 77 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
package ackhandler
import (
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/protocol"
)
// This stopWaitingManager is not supposed to satisfy the StopWaitingManager interface, which is a remnant of the legacy AckHandler, and should be remove once we drop support for QUIC 33
type stopWaitingManager struct {
largestLeastUnackedSent protocol.PacketNumber
nextLeastUnacked protocol.PacketNumber
}
func (s *stopWaitingManager) GetStopWaitingFrame() *frames.StopWaitingFrame {
if s.nextLeastUnacked <= s.largestLeastUnackedSent {
return nil
}
s.largestLeastUnackedSent = s.nextLeastUnacked
return &frames.StopWaitingFrame{
LeastUnacked: s.nextLeastUnacked,
}
}
func (s *stopWaitingManager) ReceivedAck(ack *frames.AckFrame) {
if ack.LargestAcked >= s.nextLeastUnacked {
s.nextLeastUnacked = ack.LargestAcked + 1
}
}