From 7b9d3a62174bd87e546416f6a9d91c8f4cb483b7 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 24 Sep 2018 18:54:47 -0600 Subject: [PATCH] don't try to send an ACK immediately after becoming congestion limited --- session.go | 6 ++++++ session_test.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/session.go b/session.go index c9e3743b..ce9b40f5 100644 --- a/session.go +++ b/session.go @@ -933,6 +933,12 @@ sendLoop: case ackhandler.SendNone: break sendLoop case ackhandler.SendAck: + // If we already sent packets, and the send mode switches to SendAck, + // we've just become congestion limited. + // There's no need to try to send an ACK at this moment. + if numPacketsSent > 0 { + return nil + } // We can at most send a single ACK only packet. // There will only be a new ACK after receiving new packets. // SendAck is only returned when we're congestion limited, so we don't need to set the pacingt timer. diff --git a/session_test.go b/session_test.go index 06167ad5..26cc4650 100644 --- a/session_test.go +++ b/session_test.go @@ -890,6 +890,10 @@ var _ = Describe("Session", func() { sph.EXPECT().TimeUntilSend().Return(time.Now()) sph.EXPECT().SendMode().Return(ackhandler.SendAny) sph.EXPECT().SendMode().Return(ackhandler.SendAck) + rph := mockackhandler.NewMockReceivedPacketHandler(mockCtrl) + rph.EXPECT().GetAlarmTimeout().Return(time.Now().Add(time.Hour)).Times(2) + rph.EXPECT().GetAckFrame() + sess.receivedPacketHandler = rph done := make(chan struct{}) go func() { defer GinkgoRecover()