aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Fraenkel <michael.fraenkel@gmail.com>2021-05-13 09:41:45 -0600
committerDmitri Shuralyov <dmitshur@golang.org>2021-06-02 01:35:15 +0000
commite3c9537541e35460f4fca12fe36fec822a8d53e3 (patch)
treec904bed47d6bb39a7561ab7e48741a3b8474c20f
parentcbd1ca84453fecf3825a6bb9f985823e8bc32b76 (diff)
downloadgo-e3c9537541e35460f4fca12fe36fec822a8d53e3.tar.gz
go-e3c9537541e35460f4fca12fe36fec822a8d53e3.zip
[release-branch.go1.15] net/http: prevent infinite wait during TestMissingStatusNoPanic
If the client request never makes it to the server, the outstanding accept is never broken. Change the test to always close the listening socket when the client request completes. Updates #45358 Change-Id: I744a91dfa11704e7e528163d7669c394e90456dc Reviewed-on: https://go-review.googlesource.com/c/go/+/319275 Trust: Heschi Kreinick <heschi@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit c0a7ecfae775a9d50d338e8123fac32a5d04308c) Reviewed-on: https://go-review.googlesource.com/c/go/+/320189 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>
-rw-r--r--src/net/http/transport_test.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
index 3c7b9eb4de..faa77e9ccd 100644
--- a/src/net/http/transport_test.go
+++ b/src/net/http/transport_test.go
@@ -5270,7 +5270,6 @@ func TestMissingStatusNoPanic(t *testing.T) {
ln := newLocalListener(t)
addr := ln.Addr().String()
- shutdown := make(chan bool, 1)
done := make(chan bool)
fullAddrURL := fmt.Sprintf("http://%s", addr)
raw := "HTTP/1.1 400\r\n" +
@@ -5282,10 +5281,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
"Aloha Olaa"
go func() {
- defer func() {
- ln.Close()
- close(done)
- }()
+ defer close(done)
conn, _ := ln.Accept()
if conn != nil {
@@ -5316,7 +5312,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
t.Errorf("got=%v want=%q", err, want)
}
- close(shutdown)
+ ln.Close()
<-done
}