delete flow controllers for closed streams

fixes #177
This commit is contained in:
Lucas Clemente
2016-07-28 16:45:55 +02:00
parent 5a82b35ca8
commit 3a88a8cffa
6 changed files with 26 additions and 1 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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