]> Cypherpunks repositories - gostls13.git/commit
net/http: check server shutting down before processing the request
authorwineandchord <guoqizhou19@gmail.com>
Tue, 20 Feb 2024 07:18:11 +0000 (07:18 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 4 Mar 2025 12:56:10 +0000 (04:56 -0800)
commit7181118a851bc22cf7acc604fe24940eb4926288
treec7fd4613276e76022fdfc86b640d655b25ead67b
parentbef2bb80a942a06bda2ff3aaedf46ff42d43aaf0
net/http: check server shutting down before processing the request

The root cause of issue #65802 is a small race condition that occurs between
two events:

1. During the HTTP server shutdown, a connection in an idle state is identified
and closed.
2. The connection, although idle, has just finished reading a complete request
before being closed and hasn't yet updated its state to active.

In this scenario, despite the connection being closed, the request continues to
be processed. This not only wastes server resources but also prevents the
client request from being retried.

Fixes #65802

Change-Id: Ic22abb4497be04f6c84dff059df00f2c319d8652
GitHub-Last-Rev: 426099a3e75f51b80f8ca866938f31417d75ff89
GitHub-Pull-Request: golang/go#65805
Reviewed-on: https://go-review.googlesource.com/c/go/+/565277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
src/net/http/server.go