forked from quic-go/quic-go
add method to FlowControlManager to tell if Stream contribues to connection-level flow control
This commit is contained in:
committed by
Lucas Clemente
parent
ef9baf67fc
commit
1b732a4afa
@@ -167,6 +167,17 @@ func (f *flowControlManager) UpdateWindow(streamID protocol.StreamID, offset pro
|
||||
return streamFlowController.UpdateSendWindow(offset), nil
|
||||
}
|
||||
|
||||
func (f *flowControlManager) StreamContributesToConnectionFlowControl(streamID protocol.StreamID) (bool, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
contributes, ok := f.contributesToConnectionFlowControl[streamID]
|
||||
if !ok {
|
||||
return false, errMapAccess
|
||||
}
|
||||
return contributes, nil
|
||||
}
|
||||
|
||||
func (f *flowControlManager) getFlowController(streamID protocol.StreamID) (FlowController, error) {
|
||||
streamFlowController, ok := f.streamFlowController[streamID]
|
||||
if !ok {
|
||||
|
||||
@@ -171,5 +171,26 @@ var _ = Describe("Flow Control Manager", func() {
|
||||
Expect(size).To(Equal(protocol.ByteCount(0x1000)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("streams contributing to connection-level flow control", func() {
|
||||
It("says that a stream contributes", func() {
|
||||
fcm.NewStream(5, true)
|
||||
contributes, err := fcm.StreamContributesToConnectionFlowControl(5)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(contributes).To(BeTrue())
|
||||
})
|
||||
|
||||
It("says that a stream doesn't contribute", func() {
|
||||
fcm.NewStream(3, false)
|
||||
contributes, err := fcm.StreamContributesToConnectionFlowControl(3)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(contributes).To(BeFalse())
|
||||
})
|
||||
|
||||
It("returns an error for an unknown stream", func() {
|
||||
_, err := fcm.StreamContributesToConnectionFlowControl(1337)
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -29,4 +29,5 @@ type FlowControlManager interface {
|
||||
SendWindowSize(streamID protocol.StreamID) (protocol.ByteCount, error)
|
||||
RemainingConnectionWindowSize() protocol.ByteCount
|
||||
UpdateWindow(streamID protocol.StreamID, offset protocol.ByteCount) (bool, error)
|
||||
StreamContributesToConnectionFlowControl(streamID protocol.StreamID) (bool, error)
|
||||
}
|
||||
|
||||
@@ -93,6 +93,9 @@ func (m *mockFlowControlHandler) RemainingConnectionWindowSize() protocol.ByteCo
|
||||
func (m *mockFlowControlHandler) UpdateWindow(streamID protocol.StreamID, offset protocol.ByteCount) (bool, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
func (m *mockFlowControlHandler) StreamContributesToConnectionFlowControl(streamID protocol.StreamID) (bool, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
var _ = Describe("Stream", func() {
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user