Skip to content

Commit 3d324f1

Browse files
fraenkelneild
authored andcommitted
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]>
1 parent 0eb38f2 commit 3d324f1

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

53235323
ln := newLocalListener(t)
53245324
addr := ln.Addr().String()
5325-
shutdown := make(chan bool, 1)
53265325
done := make(chan bool)
53275326
fullAddrURL := fmt.Sprintf("http://%s", addr)
53285327
raw := "HTTP/1.1 400\r\n" +
@@ -5334,10 +5333,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
53345333
"Aloha Olaa"
53355334

53365335
go func() {
5337-
defer func() {
5338-
ln.Close()
5339-
close(done)
5340-
}()
5336+
defer close(done)
53415337

53425338
conn, _ := ln.Accept()
53435339
if conn != nil {
@@ -5368,7 +5364,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
53685364
t.Errorf("got=%v want=%q", err, want)
53695365
}
53705366

5371-
close(shutdown)
5367+
ln.Close()
53725368
<-done
53735369
}
53745370

0 commit comments

Comments
 (0)