From a8f45d7959766e70cecb35cf79d5c3ca2904c1d5 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 27 Oct 2016 17:56:02 +0700 Subject: [PATCH] don't send BlockedFrames after sending the FinBit for a stream fixes #333 --- stream_framer.go | 2 +- stream_framer_test.go | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/stream_framer.go b/stream_framer.go index b702c285..45c07220 100644 --- a/stream_framer.go +++ b/stream_framer.go @@ -119,7 +119,7 @@ func (f *streamFramer) maybePopNormalFrames(maxBytes protocol.ByteCount) (res [] if f.flowControlManager.RemainingConnectionWindowSize() == 0 { // We are now connection-level FC blocked f.blockedFrameQueue = append(f.blockedFrameQueue, &frames.BlockedFrame{StreamID: 0}) - } else if sendWindowSize-frame.DataLen() == 0 { + } else if !frame.FinBit && sendWindowSize-frame.DataLen() == 0 { // We are now stream-level FC blocked f.blockedFrameQueue = append(f.blockedFrameQueue, &frames.BlockedFrame{StreamID: s.StreamID()}) } diff --git a/stream_framer_test.go b/stream_framer_test.go index e3600ca3..a866377d 100644 --- a/stream_framer_test.go +++ b/stream_framer_test.go @@ -387,13 +387,29 @@ var _ = Describe("Stream Framer", func() { It("queues and pops BLOCKED frames for individually blocked streams", func() { fcm.sendWindowSizes[stream1.StreamID()] = 3 stream1.dataForWriting = []byte("foo") - framer.PopStreamFrames(1000) + frames := framer.PopStreamFrames(1000) + Expect(frames).To(HaveLen(1)) blockedFrame := framer.PopBlockedFrame() Expect(blockedFrame).ToNot(BeNil()) Expect(blockedFrame.StreamID).To(Equal(stream1.StreamID())) Expect(framer.PopBlockedFrame()).To(BeNil()) }) + It("does not queue a stream-level BLOCKED frame after sending the FinBit frame", func() { + fcm.sendWindowSizes[stream1.StreamID()] = 5000 + stream1.dataForWriting = []byte("foo") + frames := framer.PopStreamFrames(1000) + Expect(frames).To(HaveLen(1)) + Expect(frames[0].FinBit).To(BeFalse()) + stream1.closed = 1 + frames = framer.PopStreamFrames(1000) + Expect(frames).To(HaveLen(1)) + Expect(frames[0].FinBit).To(BeTrue()) + Expect(frames[0].DataLen()).To(BeZero()) + blockedFrame := framer.PopBlockedFrame() + Expect(blockedFrame).To(BeNil()) + }) + It("queues and pops BLOCKED frames for connection blocked streams", func() { fcm.remainingConnectionWindowSize = 3 fcm.streamsContributing = []protocol.StreamID{stream1.StreamID()}