mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
0eb38f2b16
commit
3d324f127d
1 changed files with 2 additions and 6 deletions
|
|
@ -5322,7 +5322,6 @@ func TestMissingStatusNoPanic(t *testing.T) {
|
||||||
|
|
||||||
ln := newLocalListener(t)
|
ln := newLocalListener(t)
|
||||||
addr := ln.Addr().String()
|
addr := ln.Addr().String()
|
||||||
shutdown := make(chan bool, 1)
|
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
fullAddrURL := fmt.Sprintf("http://%s", addr)
|
fullAddrURL := fmt.Sprintf("http://%s", addr)
|
||||||
raw := "HTTP/1.1 400\r\n" +
|
raw := "HTTP/1.1 400\r\n" +
|
||||||
|
|
@ -5334,10 +5333,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
|
||||||
"Aloha Olaa"
|
"Aloha Olaa"
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer close(done)
|
||||||
ln.Close()
|
|
||||||
close(done)
|
|
||||||
}()
|
|
||||||
|
|
||||||
conn, _ := ln.Accept()
|
conn, _ := ln.Accept()
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
|
|
@ -5368,7 +5364,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
|
||||||
t.Errorf("got=%v want=%q", err, want)
|
t.Errorf("got=%v want=%q", err, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
close(shutdown)
|
ln.Close()
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue