diff --git a/session.go b/session.go index e9c3bec5..15942648 100644 --- a/session.go +++ b/session.go @@ -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 { diff --git a/session_test.go b/session_test.go index 266e3e70..681324d3 100644 --- a/session_test.go +++ b/session_test.go @@ -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,