http2: workaround TCPConn CloseWrite not being supported on Plan 9
This stops the tests from hanging on Plan 9.
Fixes golang/go#35904
Updates golang/go#17906
Change-Id: I2bcbb131629b217a99f9496cda0399ce21eb3020
Reviewed-on: https://go-review.googlesource.com/c/net/+/209417
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/http2/transport_test.go b/http2/transport_test.go
index f95d957..64fe1ad 100644
--- a/http2/transport_test.go
+++ b/http2/transport_test.go
@@ -832,6 +832,10 @@
ct := newClientTester(t)
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
defer close(clientDone)
var n int64 // atomic
@@ -2693,6 +2697,10 @@
ct.fr.WriteGoAway(5, ErrCodeNo, []byte(goAwayDebugData))
ct.fr.WriteGoAway(5, goAwayErrCode, nil)
ct.sc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ ct.sc.(*net.TCPConn).Close()
+ }
<-clientDone
return nil
}
@@ -2821,6 +2829,10 @@
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
defer close(clientDone)
req, _ := http.NewRequest("POST", "https://dummy.tld/", struct{ io.Reader }{io.LimitReader(neverEnding('A'), bodySize)})
@@ -3449,6 +3461,10 @@
ct := newClientTester(t)
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
defer close(clientDone)
req, _ := http.NewRequest("GET", "https://dummy.tld/", nil)
resp, err := ct.tr.RoundTrip(req)
@@ -3515,6 +3531,10 @@
ct := newClientTester(t)
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
defer close(clientDone)
req, _ := http.NewRequest("GET", "https://dummy.tld/", nil)
resp, err := ct.tr.RoundTrip(req)
@@ -3563,6 +3583,10 @@
ct := newClientTester(t)
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
req := httptest.NewRequest("GET", "https://dummy.tld/", nil)
// First request is normal to ensure the check is per stream and not per connection.
_, err := ct.tr.RoundTrip(req)
@@ -3675,6 +3699,10 @@
wg.Wait()
close(clientDone)
ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ ct.cc.(*net.TCPConn).Close()
+ }
}()
for k := 0; k < maxConcurrent+2; k++ {
wg.Add(1)
@@ -4295,6 +4323,10 @@
ct := newClientTester(t)
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
defer close(clientDone)
checkNoStreams := func() error {
@@ -4383,6 +4415,10 @@
ct := newClientTester(t)
ct.client = func() error {
defer ct.cc.(*net.TCPConn).CloseWrite()
+ if runtime.GOOS == "plan9" {
+ // CloseWrite not supported on Plan 9; Issue 17906
+ defer ct.cc.(*net.TCPConn).Close()
+ }
body := strings.NewReader(reqBody)
req, err := http.NewRequest("PUT", "https://dummy.tld/", body)
if err != nil {