diff options
| author | Bryan C. Mills <bcmills@google.com> | 2023-03-20 16:19:45 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-03-22 20:51:27 +0000 |
| commit | 11c40e349760792d0a2016633dc809025ee24b2f (patch) | |
| tree | e540af552a591393081c388f35d9b5bf5b91fc24 /src/net/http/export_test.go | |
| parent | 4d9beb2052f9ee22901afe7ad0776e375ff581e7 (diff) | |
| download | go-11c40e349760792d0a2016633dc809025ee24b2f.tar.xz | |
net/http: in the IdleConnStrsForTesting_h2 helper, omit conns that cannot be reused
In #59155, we observed that the IdleConnStrsForTesting_h2 helper
function sometimes reported extra connections after a
"client conn not usable" failure and retry. It turns out that that
state corresponds exactly to the
http2clientConnIdleState.canTakeNewRequest field, so (with a bit of
extra nethttpomithttp2 plumbing) we can use that field in the helper
to filter out the unusable connections.
Fixes #59155.
Change-Id: Ief6283c9c8c5ec47dd9f378beb0ddf720832484e
Reviewed-on: https://go-review.googlesource.com/c/go/+/477856
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/net/http/export_test.go')
| -rw-r--r-- | src/net/http/export_test.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go index fb5ab9396a..8a61e651dc 100644 --- a/src/net/http/export_test.go +++ b/src/net/http/export_test.go @@ -142,9 +142,11 @@ func (t *Transport) IdleConnStrsForTesting_h2() []string { pool.mu.Lock() defer pool.mu.Unlock() - for k, cc := range pool.conns { - for range cc { - ret = append(ret, k) + for k, ccs := range pool.conns { + for _, cc := range ccs { + if cc.idleState().canTakeNewRequest { + ret = append(ret, k) + } } } |
