forked from quic-go/quic-go
@@ -51,6 +51,14 @@ func (f *flowControlManager) NewStream(streamID protocol.StreamID, contributesTo
|
||||
f.contributesToConnectionFlowControl[streamID] = contributesToConnectionFlow
|
||||
}
|
||||
|
||||
// RemoveStream removes a closed stream from flow control
|
||||
func (f *flowControlManager) RemoveStream(streamID protocol.StreamID) {
|
||||
f.mutex.Lock()
|
||||
delete(f.streamFlowController, streamID)
|
||||
delete(f.contributesToConnectionFlowControl, streamID)
|
||||
f.mutex.Unlock()
|
||||
}
|
||||
|
||||
// UpdateHighestReceived updates the highest received byte offset for a stream
|
||||
// it adds the number of additional bytes to connection level flow control
|
||||
// streamID must not be 0 here
|
||||
|
||||
@@ -33,6 +33,14 @@ var _ = Describe("Flow Control Manager", func() {
|
||||
})
|
||||
})
|
||||
|
||||
It("removes streams", func() {
|
||||
fcm.NewStream(5, true)
|
||||
Expect(fcm.streamFlowController).To(HaveKey(protocol.StreamID(5)))
|
||||
fcm.RemoveStream(5)
|
||||
Expect(fcm.streamFlowController).ToNot(HaveKey(protocol.StreamID(5)))
|
||||
Expect(fcm.contributesToConnectionFlowControl).ToNot(HaveKey(protocol.StreamID(5)))
|
||||
})
|
||||
|
||||
Context("receiving data", func() {
|
||||
BeforeEach(func() {
|
||||
fcm.NewStream(1, false)
|
||||
|
||||
@@ -5,6 +5,7 @@ import "github.com/lucas-clemente/quic-go/protocol"
|
||||
// A FlowControlManager manages the flow control
|
||||
type FlowControlManager interface {
|
||||
NewStream(streamID protocol.StreamID, contributesToConnectionFlow bool)
|
||||
RemoveStream(streamID protocol.StreamID)
|
||||
// methods needed for receiving data
|
||||
UpdateHighestReceived(streamID protocol.StreamID, byteOffset protocol.ByteCount) error
|
||||
AddBytesRead(streamID protocol.StreamID, n protocol.ByteCount) error
|
||||
|
||||
Reference in New Issue
Block a user