test: closeIdle prevents pooling, it does not beat a waiter to the connection (BUG-3008)

Codex round 4 read CLEAN and left one wording caveat, taken because the
whole point of this comment is being exact about net/http: a connection
going idle while closeIdle is set is closed only when no request is
waiting for one. tryPutIdleConn delivers to a waiting wantConn BEFORE it
reaches the closeIdle check, so a waiter still gets the connection.

Comment text only; no code changed.
This commit is contained in:
xarmian
2026-09-10 20:18:55 +00:00
parent 685b0fab87
commit 8dfd6ad34b
+3 -2
View File
@@ -27,8 +27,9 @@ import "net/http"
// `Transport.CloseIdleConnections` closes each pooled HTTP/1 connection with
// `errCloseIdleConns` — the error in that message; HTTP/2 connections go
// through `h2transport.CloseIdleConnections()` separately. It sets
// `closeIdle`, so connections going idle afterwards are closed instead of
// pooled, until a later `queueForIdleConn` clears it (which it does not reach
// `closeIdle`, so a connection going idle afterwards is closed rather than
// pooled when no request is waiting for one — a waiter is still handed it —
// until a later `queueForIdleConn` clears the flag (which it does not reach
// when `DisableKeepAlives` is set). It also cancels the dials in progress that
// have a `cancelCtx` and are not waiting.
//