Skip to content

Commit

Permalink
rename sendStream.handleMaxStreamDataFrame to updateSendWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 12, 2021
1 parent 3bce408 commit c27f5a5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 40 deletions.
24 changes: 12 additions & 12 deletions mock_send_stream_internal_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions mock_stream_internal_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions send_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 2 additions & 8 deletions send_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 2 additions & 3 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit c27f5a5

Please sign in to comment.