forked from quic-go/quic-go
set the offset in BLOCKED and STREAM_BLOCKED frames
This commit is contained in:
@@ -79,11 +79,16 @@ func (c *baseFlowController) getWindowUpdate() protocol.ByteCount {
|
||||
return c.receiveWindow
|
||||
}
|
||||
|
||||
func (c *baseFlowController) IsBlocked() bool {
|
||||
// IsBlocked says if it is blocked by flow control.
|
||||
// If it is blocked, the offset is returned.
|
||||
func (c *baseFlowController) IsBlocked() (bool, protocol.ByteCount) {
|
||||
c.mutex.RLock()
|
||||
defer c.mutex.RUnlock()
|
||||
|
||||
return c.sendWindowSize() == 0
|
||||
if c.sendWindowSize() != 0 {
|
||||
return false, 0
|
||||
}
|
||||
return true, c.sendWindow
|
||||
}
|
||||
|
||||
// maybeAdjustWindowIncrement increases the receiveWindowIncrement if we're sending updates too often.
|
||||
|
||||
@@ -54,7 +54,9 @@ var _ = Describe("Base Flow controller", func() {
|
||||
controller.UpdateSendWindow(100)
|
||||
Expect(controller.IsBlocked()).To(BeFalse())
|
||||
controller.AddBytesSent(100)
|
||||
Expect(controller.IsBlocked()).To(BeTrue())
|
||||
blocked, offset := controller.IsBlocked()
|
||||
Expect(blocked).To(BeTrue())
|
||||
Expect(offset).To(Equal(protocol.ByteCount(100)))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
type flowController interface {
|
||||
// for sending
|
||||
SendWindowSize() protocol.ByteCount
|
||||
IsBlocked() bool
|
||||
IsBlocked() (bool, protocol.ByteCount)
|
||||
UpdateSendWindow(protocol.ByteCount)
|
||||
AddBytesSent(protocol.ByteCount)
|
||||
// for receiving
|
||||
|
||||
@@ -233,7 +233,8 @@ var _ = Describe("Stream Flow controller", func() {
|
||||
controller.connection.UpdateSendWindow(50)
|
||||
controller.UpdateSendWindow(100)
|
||||
controller.AddBytesSent(50)
|
||||
Expect(controller.connection.IsBlocked()).To(BeTrue())
|
||||
blocked, _ := controller.connection.IsBlocked()
|
||||
Expect(blocked).To(BeTrue())
|
||||
Expect(controller.IsBlocked()).To(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user