forked from quic-go/quic-go
don't send a window update after the final offset was received
Receiving a final offset means the peer is done sending on that stream, and there's no need to grant additional flow control credit.
This commit is contained in:
@@ -116,6 +116,11 @@ func (c *streamFlowController) GetWindowUpdate() protocol.ByteCount {
|
|||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
defer c.mutex.Unlock()
|
||||||
|
|
||||||
|
// if we already received the final offset for this stream, the peer won't need any additional flow control credit
|
||||||
|
if c.receivedFinalOffset {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
oldWindowIncrement := c.receiveWindowIncrement
|
oldWindowIncrement := c.receiveWindowIncrement
|
||||||
offset := c.baseFlowController.getWindowUpdate()
|
offset := c.baseFlowController.getWindowUpdate()
|
||||||
if c.receiveWindowIncrement > oldWindowIncrement { // auto-tuning enlarged the window increment
|
if c.receiveWindowIncrement > oldWindowIncrement { // auto-tuning enlarged the window increment
|
||||||
|
|||||||
@@ -193,6 +193,14 @@ var _ = Describe("Stream Flow controller", func() {
|
|||||||
Expect(controller.receiveWindowIncrement).To(Equal(2 * oldIncrement))
|
Expect(controller.receiveWindowIncrement).To(Equal(2 * oldIncrement))
|
||||||
Expect(controller.connection.(*connectionFlowController).receiveWindowIncrement).To(Equal(protocol.ByteCount(120))) // unchanged
|
Expect(controller.connection.(*connectionFlowController).receiveWindowIncrement).To(Equal(protocol.ByteCount(120))) // unchanged
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("doesn't increase the window after a final offset was already received", func() {
|
||||||
|
controller.AddBytesRead(80)
|
||||||
|
err := controller.UpdateHighestReceived(90, true)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
offset := controller.GetWindowUpdate()
|
||||||
|
Expect(offset).To(BeZero())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user