Skip to content

Commit e3c9537

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

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
@@ -5270,7 +5270,6 @@ func TestMissingStatusNoPanic(t *testing.T) {
52705270

52715271
ln := newLocalListener(t)
52725272
addr := ln.Addr().String()
5273-
shutdown := make(chan bool, 1)
52745273
done := make(chan bool)
52755274
fullAddrURL := fmt.Sprintf("http://%s", addr)
52765275
raw := "HTTP/1.1 400\r\n" +
@@ -5282,10 +5281,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
52825281
"Aloha Olaa"
52835282

52845283
go func() {
5285-
defer func() {
5286-
ln.Close()
5287-
close(done)
5288-
}()
5284+
defer close(done)
52895285

52905286
conn, _ := ln.Accept()
52915287
if conn != nil {
@@ -5316,7 +5312,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
53165312
t.Errorf("got=%v want=%q", err, want)
53175313
}
53185314

5319-
close(shutdown)
5315+
ln.Close()
53205316
<-done
53215317
}
53225318

0 commit comments

Comments
 (0)