]> Cypherpunks repositories - gostls13.git/commit
net/http: make Server.Shutdown treat new connections as idle after 5 seconds
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 28 Jun 2018 21:01:45 +0000 (21:01 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 28 Jun 2018 22:56:33 +0000 (22:56 +0000)
commita79fe5354fad08086c0a2018661f06a5f2e6eaa3
tree2f7dc93cd38843391a536d5d9273771f3b3f83e6
parent0d52c144a2564fbd5b755cd06759ab7d6870c85b
net/http: make Server.Shutdown treat new connections as idle after 5 seconds

The Server distinguishes "new" vs "idle" connections. A TCP connection
from which no bytes have yet been written is "new". A connection that
has previously served a request and is in "keep-alive" state while
waiting for a second or further request is "idle".

The graceful Server.Shutdown historically only shut down "idle"
connections, with the assumption that a "new" connection was about to
read its request and would then shut down on its own afterwards.

But apparently some clients spin up connections and don't end up using
them, so we have something that's "new" to us, but browsers or other
clients are treating as "idle" to them.

This CL tweaks our heuristic to treat a StateNew connection as
StateIdle if it's been stuck in StateNew for over 5 seconds.

Fixes #22682

Change-Id: I01ba59a6ab67755ca5ab567041b1f54aa7b7da6f
Reviewed-on: https://go-review.googlesource.com/121419
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/export_test.go
src/net/http/serve_test.go
src/net/http/server.go