From dc66c8a4e4276383dfde28f78193a3edf444f261 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 9 Nov 2019 10:32:29 +0700 Subject: [PATCH] fix handling of RESET_STREAM frames after receiving the final offset --- receive_stream.go | 3 ++- receive_stream_test.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/receive_stream.go b/receive_stream.go index 809b8371..a22eb7a1 100644 --- a/receive_stream.go +++ b/receive_stream.go @@ -269,6 +269,7 @@ func (s *receiveStream) handleResetStreamFrameImpl(frame *wire.ResetStreamFrame) if err := s.flowController.UpdateHighestReceived(frame.ByteOffset, true); err != nil { return false, err } + newlyRcvdFinalOffset := s.finalOffset == protocol.MaxByteCount s.finalOffset = frame.ByteOffset // ignore duplicate RESET_STREAM frames for this stream (after checking their final offset) @@ -281,7 +282,7 @@ func (s *receiveStream) handleResetStreamFrameImpl(frame *wire.ResetStreamFrame) error: fmt.Errorf("stream %d was reset with error code %d", s.streamID, frame.ErrorCode), } s.signalRead() - return true, nil + return newlyRcvdFinalOffset, nil } func (s *receiveStream) CloseRemote(offset protocol.ByteCount) { diff --git a/receive_stream_test.go b/receive_stream_test.go index c883b7a5..479b600f 100644 --- a/receive_stream_test.go +++ b/receive_stream_test.go @@ -616,6 +616,20 @@ var _ = Describe("Receive Stream", func() { Expect(str.handleResetStreamFrame(rst)).To(Succeed()) }) + It("doesn't call onStreamCompleted again when the final offset was already received via FinBit", func() { + mockSender.EXPECT().queueControlFrame(gomock.Any()) + str.CancelRead(1234) + mockSender.EXPECT().onStreamCompleted(streamID) + mockFC.EXPECT().Abandon() + mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Times(2) + Expect(str.handleStreamFrame(&wire.StreamFrame{ + StreamID: streamID, + Offset: rst.ByteOffset, + FinBit: true, + })).To(Succeed()) + Expect(str.handleResetStreamFrame(rst)).To(Succeed()) + }) + It("doesn't do anyting when it was closed for shutdown", func() { str.closeForShutdown(nil) err := str.handleResetStreamFrame(rst)