From e0801262bc9052e7ffb61a889657a0c2f5674581 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 18 May 2016 12:06:14 +0700 Subject: [PATCH] actually send Blocked frames fixes #100 --- stream.go | 2 ++ stream_test.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/stream.go b/stream.go index 50745e36..a20c35f8 100644 --- a/stream.go +++ b/stream.go @@ -185,6 +185,8 @@ func (s *stream) Write(p []byte) (int, error) { dataWritten += dataLen s.flowController.AddBytesSent(protocol.ByteCount(dataLen)) s.writeOffset += protocol.ByteCount(dataLen) + + s.maybeTriggerBlocked() } return len(p), nil diff --git a/stream_test.go b/stream_test.go index 2258c651..7a915515 100644 --- a/stream_test.go +++ b/stream_test.go @@ -374,6 +374,23 @@ var _ = Describe("Stream", func() { Expect(handler.receivedBlockedCalled).To(BeTrue()) Expect(handler.receivedBlockedForStream).To(Equal(str.streamID)) }) + + It("notifies the session as soon as a stream is reaching the end of the window", func() { + str.flowController.sendFlowControlWindow = 4 + str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) + Expect(handler.receivedBlockedCalled).To(BeTrue()) + Expect(handler.receivedBlockedForStream).To(Equal(str.streamID)) + }) + + It("notifies the session as soon as a stream is flow control blocked", func() { + str.flowController.sendFlowControlWindow = 2 + go func() { + str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) + }() + time.Sleep(time.Millisecond) + Expect(handler.receivedBlockedCalled).To(BeTrue()) + Expect(handler.receivedBlockedForStream).To(Equal(str.streamID)) + }) }) Context("flow control window updating, for receiving", func() {