forked from quic-go/quic-go
remove MaybeTriggerBlocked from flowController
This commit is contained in:
@@ -14,7 +14,6 @@ type flowController struct {
|
||||
|
||||
bytesSent protocol.ByteCount
|
||||
sendFlowControlWindow protocol.ByteCount
|
||||
lastBlockedSentForOffset protocol.ByteCount
|
||||
|
||||
bytesRead protocol.ByteCount
|
||||
highestReceived protocol.ByteCount
|
||||
@@ -122,28 +121,6 @@ func (c *flowController) AddBytesRead(n protocol.ByteCount) {
|
||||
c.bytesRead += n
|
||||
}
|
||||
|
||||
// MaybeTriggerBlocked determines if it is necessary to send a Blocked for this stream
|
||||
// it makes sure that only one Blocked is sent for each offset
|
||||
func (c *flowController) MaybeTriggerBlocked() bool {
|
||||
if c.SendWindowSize() != 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
c.mutex.RLock()
|
||||
sendFlowControlWindow := c.getSendFlowControlWindow()
|
||||
c.mutex.RUnlock()
|
||||
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
|
||||
if c.lastBlockedSentForOffset == sendFlowControlWindow {
|
||||
return false
|
||||
}
|
||||
|
||||
c.lastBlockedSentForOffset = sendFlowControlWindow
|
||||
return true
|
||||
}
|
||||
|
||||
// MaybeTriggerWindowUpdate determines if it is necessary to send a WindowUpdate
|
||||
// if so, it returns true and the offset of the window
|
||||
func (c *flowController) MaybeTriggerWindowUpdate() (bool, protocol.ByteCount) {
|
||||
|
||||
@@ -131,34 +131,6 @@ var _ = Describe("Flow controller", func() {
|
||||
setConnectionParametersManagerWindow(cpm, "sendConnectionFlowControlWindow", 9000)
|
||||
Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(7000)))
|
||||
})
|
||||
|
||||
Context("Blocked", func() {
|
||||
var sendFlowControlWindow protocol.ByteCount = 20
|
||||
|
||||
BeforeEach(func() {
|
||||
controller.sendFlowControlWindow = sendFlowControlWindow
|
||||
})
|
||||
|
||||
It("sends a Blocked when there's no space left in the window", func() {
|
||||
controller.bytesSent = sendFlowControlWindow
|
||||
Expect(controller.MaybeTriggerBlocked()).To(BeTrue())
|
||||
})
|
||||
|
||||
It("does not send a Blocked when there's still space in the window", func() {
|
||||
controller.bytesSent = sendFlowControlWindow - 1
|
||||
Expect(controller.MaybeTriggerBlocked()).To(BeFalse())
|
||||
})
|
||||
|
||||
It("only sends one Blocked for one offset", func() {
|
||||
controller.bytesSent = sendFlowControlWindow
|
||||
Expect(controller.MaybeTriggerBlocked()).To(BeTrue())
|
||||
Expect(controller.MaybeTriggerBlocked()).To(BeFalse())
|
||||
updateSuccessfull := controller.UpdateSendWindow(sendFlowControlWindow + 1)
|
||||
Expect(updateSuccessfull).To(BeTrue())
|
||||
controller.bytesSent = sendFlowControlWindow + 1
|
||||
Expect(controller.MaybeTriggerBlocked()).To(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("receive flow control", func() {
|
||||
|
||||
Reference in New Issue
Block a user