diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2019-05-25 18:47:22 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-05-28 00:54:10 +0000 |
| commit | 3970667d958eadbe591400ac9a53051a39f40ea2 (patch) | |
| tree | 08d3758a155fb9427cda21bc0cb31daab19734d2 /src/net/http/export_test.go | |
| parent | f736de04aa52d4889760ecfe4380da01aaf4758f (diff) | |
| download | go-3970667d958eadbe591400ac9a53051a39f40ea2.tar.xz | |
net/http: fix TestTransportServerClosingUnexpectedly flake
Fixes #32119
Change-Id: I8cf2e2e69737e2485568af91ab75149f3cf66781
Reviewed-on: https://go-review.googlesource.com/c/go/+/178918
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/http/export_test.go')
| -rw-r--r-- | src/net/http/export_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go index b6965c239e..c33b88860a 100644 --- a/src/net/http/export_test.go +++ b/src/net/http/export_test.go @@ -244,3 +244,18 @@ func ExportSetH2GoawayTimeout(d time.Duration) (restore func()) { } func (r *Request) ExportIsReplayable() bool { return r.isReplayable() } + +// ExportCloseTransportConnsAbruptly closes all idle connections from +// tr in an abrupt way, just reaching into the underlying Conns and +// closing them, without telling the Transport or its persistConns +// that it's doing so. This is to simulate the server closing connections +// on the Transport. +func ExportCloseTransportConnsAbruptly(tr *Transport) { + tr.idleMu.Lock() + for _, pcs := range tr.idleConn { + for _, pc := range pcs { + pc.conn.Close() + } + } + tr.idleMu.Unlock() +} |
