Move calls to GetWindowUpdate out of the send loop

This commit is contained in:
Lucas Clemente
2017-06-20 11:50:43 +02:00
committed by Lucas Clemente
parent 9d428d92f7
commit fc8d937fce
2 changed files with 9 additions and 9 deletions

View File

@@ -562,19 +562,19 @@ func (s *session) handleCloseError(closeErr closeError) error {
}
func (s *session) sendPacket() error {
// Get WindowUpdate frames
// this call triggers the flow controller to increase the flow control windows, if necessary
windowUpdateFrames := s.getWindowUpdateFrames()
for _, wuf := range windowUpdateFrames {
s.packer.QueueControlFrameForNextPacket(wuf)
}
// Repeatedly try sending until we don't have any more data, or run out of the congestion window
for {
if !s.sentPacketHandler.SendingAllowed() {
return nil
}
// get WindowUpdate frames
// this call triggers the flow controller to increase the flow control windows, if necessary
windowUpdateFrames := s.getWindowUpdateFrames()
for _, wuf := range windowUpdateFrames {
s.packer.QueueControlFrameForNextPacket(wuf)
}
// check for retransmissions first
for {
retransmitPacket := s.sentPacketHandler.DequeuePacketForRetransmission()
@@ -646,6 +646,7 @@ func (s *session) sendPacket() error {
for _, f := range windowUpdateFrames {
s.packer.QueueControlFrameForNextPacket(f)
}
windowUpdateFrames = nil
err = s.sendPackedPacket(packet)
if err != nil {

View File

@@ -1069,14 +1069,13 @@ var _ = Describe("Session", func() {
Expect(ok).To(BeTrue())
})
It("retransmits a WindowUpdates if it hasn't already sent a WindowUpdate with a higher ByteOffset", func() {
It("retransmits a WindowUpdate if it hasn't already sent a WindowUpdate with a higher ByteOffset", func() {
_, err := sess.GetOrOpenStream(5)
Expect(err).ToNot(HaveOccurred())
fcm := mocks_fc.NewMockFlowControlManager(mockCtrl)
sess.flowControlManager = fcm
fcm.EXPECT().GetWindowUpdates()
fcm.EXPECT().GetReceiveWindow(protocol.StreamID(5)).Return(protocol.ByteCount(0x1000), nil)
fcm.EXPECT().GetWindowUpdates()
wuf := &frames.WindowUpdateFrame{
StreamID: 5,
ByteOffset: 0x1000,