Skip to content

Commit 1613be8

Browse files
fraenkeldmitshur
authored andcommitted
[release-branch.go1.16] 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 <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> (cherry picked from commit c0a7ecf) Reviewed-on: https://go-review.googlesource.com/c/go/+/320190 Reviewed-by: Damien Neil <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 0410005 commit 1613be8

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/net/http/transport_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5314,7 +5314,6 @@ func TestMissingStatusNoPanic(t *testing.T) {
53145314

53155315
ln := newLocalListener(t)
53165316
addr := ln.Addr().String()
5317-
shutdown := make(chan bool, 1)
53185317
done := make(chan bool)
53195318
fullAddrURL := fmt.Sprintf("http://%s", addr)
53205319
raw := "HTTP/1.1 400\r\n" +
@@ -5326,10 +5325,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
53265325
"Aloha Olaa"
53275326

53285327
go func() {
5329-
defer func() {
5330-
ln.Close()
5331-
close(done)
5332-
}()
5328+
defer close(done)
53335329

53345330
conn, _ := ln.Accept()
53355331
if conn != nil {
@@ -5360,7 +5356,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
53605356
t.Errorf("got=%v want=%q", err, want)
53615357
}
53625358

5363-
close(shutdown)
5359+
ln.Close()
53645360
<-done
53655361
}
53665362

0 commit comments

Comments
 (0)