diff --git a/src/net/tcp_test.go b/src/net/tcp_test.go index 2191c91fa350e..30c5762592e89 100644 --- a/src/net/tcp_test.go +++ b/src/net/tcp_test.go @@ -539,9 +539,12 @@ func TestTCPStress(t *testing.T) { if err != nil { t.Fatal(err) } - defer ln.Close() + done := make(chan bool) // Acceptor. go func() { + defer func() { + done <- true + }() for { c, err := ln.Accept() if err != nil { @@ -559,7 +562,6 @@ func TestTCPStress(t *testing.T) { }(c) } }() - done := make(chan bool) for i := 0; i < conns; i++ { // Client connection. go func() { @@ -583,4 +585,6 @@ func TestTCPStress(t *testing.T) { for i := 0; i < conns; i++ { <-done } + ln.Close() + <-done }