don’t add bytes read after receiving a RST_STREAM to flow controller

This commit is contained in:
Marten Seemann 2017-01-09 10:15:12 +07:00
parent d246a295d2
commit 980d0e398f
No known key found for this signature in database
GPG key ID: 3603F40B121FCDEA
2 changed files with 21 additions and 1 deletions

View file

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