mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
connection: only queue flow control frames once when sending a batch
This commit is contained in:
parent
d1bbde3580
commit
db4e929ccf
2 changed files with 30 additions and 20 deletions
|
@ -1805,6 +1805,27 @@ func (s *connection) sendPackets() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isBlocked, offset := s.connFlowController.IsNewlyBlocked(); isBlocked {
|
||||||
|
s.framer.QueueControlFrame(&wire.DataBlockedFrame{MaximumData: offset})
|
||||||
|
}
|
||||||
|
s.windowUpdateQueue.QueueAll()
|
||||||
|
|
||||||
|
if !s.handshakeConfirmed {
|
||||||
|
packet, err := s.packer.PackCoalescedPacket(false, s.mtuDiscoverer.CurrentSize(), s.version)
|
||||||
|
if err != nil || packet == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.sentFirstPacket = true
|
||||||
|
s.sendPackedCoalescedPacket(packet, now)
|
||||||
|
sendMode := s.sentPacketHandler.SendMode()
|
||||||
|
if sendMode == ackhandler.SendPacingLimited {
|
||||||
|
s.resetPacingDeadline()
|
||||||
|
} else if sendMode == ackhandler.SendAny {
|
||||||
|
s.pacingDeadline = deadlineSendImmediately
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
sent, err := s.sendPacket(now)
|
sent, err := s.sendPacket(now)
|
||||||
if err != nil || !sent {
|
if err != nil || !sent {
|
||||||
|
@ -1821,11 +1842,7 @@ func (s *connection) sendPackets() error {
|
||||||
|
|
||||||
sendMode := s.sentPacketHandler.SendMode()
|
sendMode := s.sentPacketHandler.SendMode()
|
||||||
if sendMode == ackhandler.SendPacingLimited {
|
if sendMode == ackhandler.SendPacingLimited {
|
||||||
deadline := s.sentPacketHandler.TimeUntilSend()
|
s.resetPacingDeadline()
|
||||||
if deadline.IsZero() {
|
|
||||||
deadline = deadlineSendImmediately
|
|
||||||
}
|
|
||||||
s.pacingDeadline = deadline
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if sendMode != ackhandler.SendAny {
|
if sendMode != ackhandler.SendAny {
|
||||||
|
@ -1834,6 +1851,14 @@ func (s *connection) sendPackets() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *connection) resetPacingDeadline() {
|
||||||
|
deadline := s.sentPacketHandler.TimeUntilSend()
|
||||||
|
if deadline.IsZero() {
|
||||||
|
deadline = deadlineSendImmediately
|
||||||
|
}
|
||||||
|
s.pacingDeadline = deadline
|
||||||
|
}
|
||||||
|
|
||||||
func (s *connection) maybeSendAckOnlyPacket() error {
|
func (s *connection) maybeSendAckOnlyPacket() error {
|
||||||
if !s.handshakeConfirmed {
|
if !s.handshakeConfirmed {
|
||||||
packet, err := s.packer.PackCoalescedPacket(true, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err := s.packer.PackCoalescedPacket(true, s.mtuDiscoverer.CurrentSize(), s.version)
|
||||||
|
@ -1903,20 +1928,6 @@ func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connection) sendPacket(now time.Time) (bool, error) {
|
func (s *connection) sendPacket(now time.Time) (bool, error) {
|
||||||
if isBlocked, offset := s.connFlowController.IsNewlyBlocked(); isBlocked {
|
|
||||||
s.framer.QueueControlFrame(&wire.DataBlockedFrame{MaximumData: offset})
|
|
||||||
}
|
|
||||||
s.windowUpdateQueue.QueueAll()
|
|
||||||
|
|
||||||
if !s.handshakeConfirmed {
|
|
||||||
packet, err := s.packer.PackCoalescedPacket(false, s.mtuDiscoverer.CurrentSize(), s.version)
|
|
||||||
if err != nil || packet == nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
s.sentFirstPacket = true
|
|
||||||
s.sendPackedCoalescedPacket(packet, now)
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
p, buffer, err := s.packer.PackPacket(false, now, s.mtuDiscoverer.CurrentSize(), s.version)
|
p, buffer, err := s.packer.PackPacket(false, now, s.mtuDiscoverer.CurrentSize(), s.version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errNothingToPack {
|
if err == errNothingToPack {
|
||||||
|
|
|
@ -1256,7 +1256,6 @@ var _ = Describe("Connection", func() {
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
fc := mocks.NewMockConnectionFlowController(mockCtrl)
|
fc := mocks.NewMockConnectionFlowController(mockCtrl)
|
||||||
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
|
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
|
||||||
fc.EXPECT().IsNewlyBlocked()
|
|
||||||
p, buffer := getShortHeaderPacket(1)
|
p, buffer := getShortHeaderPacket(1)
|
||||||
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
|
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
|
||||||
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
|
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue