rename sendStream.handleMaxStreamDataFrame to updateSendWindow

This commit is contained in:
Marten Seemann 2021-03-12 13:36:23 +08:00
parent 3bce408c8d
commit c27f5a55b3
7 changed files with 33 additions and 40 deletions

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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())

View file

@ -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
}

View file

@ -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() {

View file

@ -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 (