diff --git a/mock_send_stream_internal_test.go b/mock_send_stream_internal_test.go index d37a1bfd..0a561aa7 100644 --- a/mock_send_stream_internal_test.go +++ b/mock_send_stream_internal_test.go @@ -133,18 +133,6 @@ func (mr *MockSendStreamIMockRecorder) closeForShutdown(arg0 interface{}) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "closeForShutdown", reflect.TypeOf((*MockSendStreamI)(nil).closeForShutdown), arg0) } -// handleMaxStreamDataFrame mocks base method. -func (m *MockSendStreamI) handleMaxStreamDataFrame(arg0 *wire.MaxStreamDataFrame) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "handleMaxStreamDataFrame", arg0) -} - -// handleMaxStreamDataFrame indicates an expected call of handleMaxStreamDataFrame. -func (mr *MockSendStreamIMockRecorder) handleMaxStreamDataFrame(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleMaxStreamDataFrame", reflect.TypeOf((*MockSendStreamI)(nil).handleMaxStreamDataFrame), arg0) -} - // handleStopSendingFrame mocks base method. func (m *MockSendStreamI) handleStopSendingFrame(arg0 *wire.StopSendingFrame) { m.ctrl.T.Helper() @@ -185,3 +173,15 @@ func (mr *MockSendStreamIMockRecorder) popStreamFrame(maxBytes interface{}) *gom mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "popStreamFrame", reflect.TypeOf((*MockSendStreamI)(nil).popStreamFrame), maxBytes) } + +// updateSendWindow mocks base method. +func (m *MockSendStreamI) updateSendWindow(arg0 protocol.ByteCount) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "updateSendWindow", arg0) +} + +// updateSendWindow indicates an expected call of updateSendWindow. +func (mr *MockSendStreamIMockRecorder) updateSendWindow(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "updateSendWindow", reflect.TypeOf((*MockSendStreamI)(nil).updateSendWindow), arg0) +} diff --git a/mock_stream_internal_test.go b/mock_stream_internal_test.go index 16bc72fc..1fa35c75 100644 --- a/mock_stream_internal_test.go +++ b/mock_stream_internal_test.go @@ -202,18 +202,6 @@ func (mr *MockStreamIMockRecorder) getWindowUpdate() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getWindowUpdate", reflect.TypeOf((*MockStreamI)(nil).getWindowUpdate)) } -// handleMaxStreamDataFrame mocks base method. -func (m *MockStreamI) handleMaxStreamDataFrame(arg0 *wire.MaxStreamDataFrame) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "handleMaxStreamDataFrame", arg0) -} - -// handleMaxStreamDataFrame indicates an expected call of handleMaxStreamDataFrame. -func (mr *MockStreamIMockRecorder) handleMaxStreamDataFrame(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleMaxStreamDataFrame", reflect.TypeOf((*MockStreamI)(nil).handleMaxStreamDataFrame), arg0) -} - // handleResetStreamFrame mocks base method. func (m *MockStreamI) handleResetStreamFrame(arg0 *wire.ResetStreamFrame) error { m.ctrl.T.Helper() @@ -282,3 +270,15 @@ func (mr *MockStreamIMockRecorder) popStreamFrame(maxBytes interface{}) *gomock. mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "popStreamFrame", reflect.TypeOf((*MockStreamI)(nil).popStreamFrame), maxBytes) } + +// updateSendWindow mocks base method. +func (m *MockStreamI) updateSendWindow(arg0 protocol.ByteCount) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "updateSendWindow", arg0) +} + +// updateSendWindow indicates an expected call of updateSendWindow. +func (mr *MockStreamIMockRecorder) updateSendWindow(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "updateSendWindow", reflect.TypeOf((*MockStreamI)(nil).updateSendWindow), arg0) +} diff --git a/send_stream.go b/send_stream.go index 32366683..1295e2b3 100644 --- a/send_stream.go +++ b/send_stream.go @@ -20,7 +20,7 @@ type sendStreamI interface { hasData() bool popStreamFrame(maxBytes protocol.ByteCount) (*ackhandler.Frame, bool) closeForShutdown(error) - handleMaxStreamDataFrame(*wire.MaxStreamDataFrame) + updateSendWindow(protocol.ByteCount) } type sendStream struct { @@ -437,12 +437,12 @@ func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, wr } } -func (s *sendStream) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) { +func (s *sendStream) updateSendWindow(limit protocol.ByteCount) { s.mutex.Lock() hasStreamData := s.dataForWriting != nil || s.nextFrame != nil s.mutex.Unlock() - s.flowController.UpdateSendWindow(frame.MaximumStreamData) + s.flowController.UpdateSendWindow(limit) if hasStreamData { s.sender.onHasStreamData(s.streamID) } diff --git a/send_stream_test.go b/send_stream_test.go index a0d70545..ea2d8c89 100644 --- a/send_stream_test.go +++ b/send_stream_test.go @@ -652,10 +652,7 @@ var _ = Describe("Send Stream", func() { Context("handling MAX_STREAM_DATA frames", func() { It("informs the flow controller", func() { mockFC.EXPECT().UpdateSendWindow(protocol.ByteCount(0x1337)) - str.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{ - StreamID: streamID, - MaximumStreamData: 0x1337, - }) + str.updateSendWindow(0x1337) }) It("says when it has data for sending", func() { @@ -670,10 +667,7 @@ var _ = Describe("Send Stream", func() { }() waitForWrite() mockSender.EXPECT().onHasStreamData(streamID) - str.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{ - StreamID: streamID, - MaximumStreamData: 42, - }) + str.updateSendWindow(42) // make sure the Write go routine returns str.closeForShutdown(nil) Eventually(done).Should(BeClosed()) diff --git a/session.go b/session.go index aedb16ab..36d46740 100644 --- a/session.go +++ b/session.go @@ -1272,7 +1272,7 @@ func (s *session) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) error // stream is closed and already garbage collected return nil } - str.handleMaxStreamDataFrame(frame) + str.updateSendWindow(frame.MaximumStreamData) return nil } diff --git a/session_test.go b/session_test.go index 60a4aa23..30588cef 100644 --- a/session_test.go +++ b/session_test.go @@ -220,9 +220,8 @@ var _ = Describe("Session", func() { } str := NewMockSendStreamI(mockCtrl) streamManager.EXPECT().GetOrOpenSendStream(protocol.StreamID(12345)).Return(str, nil) - str.EXPECT().handleMaxStreamDataFrame(f) - err := sess.handleMaxStreamDataFrame(f) - Expect(err).ToNot(HaveOccurred()) + str.EXPECT().updateSendWindow(protocol.ByteCount(0x1337)) + Expect(sess.handleMaxStreamDataFrame(f)).To(Succeed()) }) It("updates the flow control window of the connection", func() { diff --git a/stream.go b/stream.go index deeabb1e..3237dc57 100644 --- a/stream.go +++ b/stream.go @@ -61,7 +61,7 @@ type streamI interface { hasData() bool handleStopSendingFrame(*wire.StopSendingFrame) popStreamFrame(maxBytes protocol.ByteCount) (*ackhandler.Frame, bool) - handleMaxStreamDataFrame(*wire.MaxStreamDataFrame) + updateSendWindow(protocol.ByteCount) } var (