From f0c9ae5452832f0f9e4dfa38f756ae9137577482 Mon Sep 17 00:00:00 2001 From: Dan Peterson Date: Thu, 22 Oct 2020 19:25:56 -0300 Subject: net/http: use exponential backoff for polling in Server.Shutdown Instead of always polling 500ms, start with an interval of 1ms and exponentially back off to at most 500ms. 10% jitter is added to each interval. This makes Shutdown more responsive when connections and listeners close quickly. Also removes the need for the polling interval to be changed in tests since if tests' connections and listeners close quickly Shutdown will also return quickly. Fixes #42156 Change-Id: I5e59844a2980c09adebff57ae8b58817965e6db4 Reviewed-on: https://go-review.googlesource.com/c/go/+/264479 Run-TryBot: Emmanuel Odeke Reviewed-by: Emmanuel Odeke Trust: Emmanuel Odeke Trust: Bryan C. Mills --- src/net/http/http_test.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/net/http/http_test.go') diff --git a/src/net/http/http_test.go b/src/net/http/http_test.go index 49c2b4196a..3f1d7cee71 100644 --- a/src/net/http/http_test.go +++ b/src/net/http/http_test.go @@ -13,13 +13,8 @@ import ( "os/exec" "reflect" "testing" - "time" ) -func init() { - shutdownPollInterval = 5 * time.Millisecond -} - func TestForeachHeaderElement(t *testing.T) { tests := []struct { in string -- cgit v1.2.1