fix handling of duplicate FIN bits after a stream was canceled

This commit is contained in:
Marten Seemann 2019-11-09 10:03:37 +07:00
parent e6e343fc39
commit 63585d1b5e
2 changed files with 23 additions and 2 deletions

View file

@ -236,11 +236,13 @@ func (s *receiveStream) handleStreamFrameImpl(frame *wire.StreamFrame) (bool /*
if err := s.flowController.UpdateHighestReceived(maxOffset, frame.FinBit); err != nil {
return false, err
}
var newlyRcvdFinalOffset bool
if frame.FinBit {
newlyRcvdFinalOffset = s.finalOffset == protocol.MaxByteCount
s.finalOffset = maxOffset
}
if s.canceledRead {
return frame.FinBit, nil
return newlyRcvdFinalOffset, nil
}
if err := s.frameQueue.Push(frame.Data, frame.Offset, frame.PutBack); err != nil {
return false, err

View file

@ -538,6 +538,25 @@ var _ = Describe("Receive Stream", func() {
FinBit: true,
})).To(Succeed())
})
It("handles duplicate FinBits after the stream was canceled", func() {
mockSender.EXPECT().queueControlFrame(gomock.Any())
str.CancelRead(1234)
gomock.InOrder(
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(1000), true),
mockFC.EXPECT().Abandon(),
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(1000), true),
)
mockSender.EXPECT().onStreamCompleted(streamID)
Expect(str.handleStreamFrame(&wire.StreamFrame{
Offset: 1000,
FinBit: true,
})).To(Succeed())
Expect(str.handleStreamFrame(&wire.StreamFrame{
Offset: 1000,
FinBit: true,
})).To(Succeed())
})
})
Context("receiving RESET_STREAM frames", func() {
@ -564,7 +583,7 @@ var _ = Describe("Receive Stream", func() {
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true),
mockFC.EXPECT().Abandon(),
)
str.handleResetStreamFrame(rst)
Expect(str.handleResetStreamFrame(rst)).To(Succeed())
Eventually(done).Should(BeClosed())
})