forked from quic-go/quic-go
don’t add bytes read after receiving a RST_STREAM to flow controller
This commit is contained in:
@@ -120,7 +120,10 @@ func (s *stream) Read(p []byte) (int, error) {
|
||||
bytesRead += m
|
||||
s.readOffset += protocol.ByteCount(m)
|
||||
|
||||
s.flowControlManager.AddBytesRead(s.streamID, protocol.ByteCount(m))
|
||||
// when a RST_STREAM was received, the was already informed about the final byteOffset for this stream
|
||||
if !s.resetRemotely.Get() {
|
||||
s.flowControlManager.AddBytesRead(s.streamID, protocol.ByteCount(m))
|
||||
}
|
||||
s.onData() // so that a possible WINDOW_UPDATE is sent
|
||||
|
||||
if s.readPosInFrame >= int(frame.DataLen()) {
|
||||
|
||||
@@ -64,6 +64,7 @@ func (m *mockFlowControlHandler) AddBytesRead(streamID protocol.StreamID, n prot
|
||||
}
|
||||
|
||||
func (m *mockFlowControlHandler) ResetStream(streamID protocol.StreamID, byteOffset protocol.ByteCount) error {
|
||||
m.bytesRead = byteOffset
|
||||
return m.UpdateHighestReceived(streamID, byteOffset)
|
||||
}
|
||||
|
||||
@@ -494,6 +495,22 @@ var _ = Describe("Stream", func() {
|
||||
Expect(n).To(Equal(1))
|
||||
})
|
||||
|
||||
It("doesn't inform the flow controller about bytes read after receiving the remote error", func() {
|
||||
str.flowControlManager = newMockFlowControlHandler()
|
||||
frame := frames.StreamFrame{
|
||||
Offset: 0,
|
||||
StreamID: 5,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.flowControlManager.ResetStream(5, 4)
|
||||
str.RegisterRemoteError(testErr)
|
||||
b := make([]byte, 3)
|
||||
_, err := str.Read(b)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str.flowControlManager.(*mockFlowControlHandler).bytesRead).To(BeEquivalentTo(4))
|
||||
})
|
||||
|
||||
It("stops writing after receiving a remote error", func() {
|
||||
var writeReturned bool
|
||||
var n int
|
||||
|
||||
Reference in New Issue
Block a user