Commit c5088f49 authored by Mikio Hara's avatar Mikio Hara

go.net/netutil: fix unintentional test deadlock on resource starvation

It's been observed when the node under test has a tiny resource
configutation or package http has changed the behavior of its own
active connection pool.

For example,
http://build.golang.org/log/8912bc0944628cf1b4fe4063a77d36d19f9dd6a3

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/78640043
parent 68f5bd3a
......@@ -45,7 +45,8 @@ func TestLimitListener(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
r, err := http.Get("http://" + l.Addr().String())
c := http.Client{Timeout: 3 * time.Second}
r, err := c.Get("http://" + l.Addr().String())
if err != nil {
t.Logf("Get: %v", err)
atomic.AddInt32(&failed, 1)
......@@ -60,6 +61,6 @@ func TestLimitListener(t *testing.T) {
// We expect some Gets to fail as the kernel's accept queue is filled,
// but most should succeed.
if failed >= num/2 {
t.Errorf("too many Gets failed")
t.Errorf("too many Gets failed: %v", failed)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment