]> Cypherpunks repositories - gostls13.git/commit
net/http: use exponential backoff for polling in Server.Shutdown
authorDan Peterson <dpiddy@gmail.com>
Thu, 22 Oct 2020 22:25:56 +0000 (19:25 -0300)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Tue, 27 Oct 2020 18:38:48 +0000 (18:38 +0000)
commitf0c9ae5452832f0f9e4dfa38f756ae9137577482
tree865569ff56bad1e8b8a0d5c50dc89e2aaeaa2989
parentc3c6fbf31419d37b0ae7d99b5378f6f8e9080b24
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 <emmanuel@orijtech.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Bryan C. Mills <bcmills@google.com>
src/net/http/http_test.go
src/net/http/server.go