don't count retransmission as sent bytes for connection flow control

This commit is contained in:
Marten Seemann
2016-06-16 16:05:37 +07:00
committed by Lucas Clemente
parent 8a9d70488a
commit b38d4b37fe
3 changed files with 20 additions and 2 deletions

View File

@@ -148,8 +148,9 @@ func (q *streamFrameQueue) Pop(maxLength protocol.ByteCount) (*frames.StreamFram
q.byteLen -= frame.DataLen()
// TODO: don't add retransmission to connection-level flow control
q.flowControlManager.AddBytesSent(streamID, frame.DataLen())
if !isPrioFrame {
q.flowControlManager.AddBytesSent(streamID, frame.DataLen())
}
q.len--
return frame, nil

View File

@@ -220,6 +220,20 @@ var _ = Describe("streamFrameQueue", func() {
Expect(frame).To(BeNil())
})
It("tells the FlowControlManager how many bytes it sent", func() {
queue.Push(frame1, false)
_, err := queue.Pop(1000)
Expect(err).ToNot(HaveOccurred())
Expect(queue.flowControlManager.(*mockFlowControlHandler).bytesSent).To(Equal(frame1.DataLen()))
})
It("doesn't add the bytes sent to the FlowControlManager if it was a retransmission", func() {
queue.Push(prioFrame1, true)
_, err := queue.Pop(1000)
Expect(err).ToNot(HaveOccurred())
Expect(queue.flowControlManager.(*mockFlowControlHandler).bytesSent).To(BeZero())
})
It("returns normal frames if no prio frames are available", func() {
queue.Push(frame1, false)
queue.Push(frame2, false)

View File

@@ -46,6 +46,7 @@ type mockFlowControlHandler struct {
remainingConnectionWindowSize protocol.ByteCount
bytesReadForStream protocol.StreamID
bytesRead protocol.ByteCount
bytesSent protocol.ByteCount
highestReceivedForStream protocol.StreamID
highestReceived protocol.ByteCount
@@ -85,8 +86,10 @@ func (m *mockFlowControlHandler) UpdateHighestReceived(streamID protocol.StreamI
}
func (m *mockFlowControlHandler) AddBytesSent(streamID protocol.StreamID, n protocol.ByteCount) error {
m.bytesSent += n
return nil
}
func (m *mockFlowControlHandler) SendWindowSize(streamID protocol.StreamID) (protocol.ByteCount, error) {
return m.sendWindowSizes[streamID], nil
}