From 0d6647ed8c1b7818d9a20f454cf17818a8eef5f3 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 17 Feb 2017 19:47:09 +0700 Subject: [PATCH] fix auto-tuning of connection-level flow control window fixes #424 --- flowcontrol/flow_controller.go | 1 + flowcontrol/flow_controller_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/flowcontrol/flow_controller.go b/flowcontrol/flow_controller.go index 928438e6..6a0d3855 100644 --- a/flowcontrol/flow_controller.go +++ b/flowcontrol/flow_controller.go @@ -184,6 +184,7 @@ func (c *flowController) maybeAdjustWindowIncrement() { func (c *flowController) EnsureMinimumWindowIncrement(inc protocol.ByteCount) { if inc > c.receiveWindowIncrement { c.receiveWindowIncrement = utils.MinByteCount(inc, c.maxReceiveWindowIncrement) + c.lastWindowUpdateTime = time.Time{} // disables autotuning for the next window update } } diff --git a/flowcontrol/flow_controller_test.go b/flowcontrol/flow_controller_test.go index b496526f..1c822997 100644 --- a/flowcontrol/flow_controller_test.go +++ b/flowcontrol/flow_controller_test.go @@ -352,6 +352,17 @@ var _ = Describe("Flow controller", func() { controller.EnsureMinimumWindowIncrement(2 * max) Expect(controller.receiveWindowIncrement).To(Equal(max)) }) + + It("doesn't auto-tune the window after the increment was increased", func() { + setRtt(10 * time.Millisecond) + controller.bytesRead = 9900 // receive window is 10000 + controller.lastWindowUpdateTime = time.Now().Add(-10 * time.Millisecond) + controller.EnsureMinimumWindowIncrement(912) + necessary, newIncrement, offset := controller.MaybeUpdateWindow() + Expect(necessary).To(BeTrue()) + Expect(newIncrement).To(BeZero()) // no auto-tuning + Expect(offset).To(Equal(protocol.ByteCount(9900 + 912))) + }) }) }) })