Commit 11ac72a1 authored by Mikio Hara's avatar Mikio Hara

net: fix race in TestTCPStress

Fixes #13704.

Change-Id: I7afef5058fa88b0de41213cf46219b684369f47f
Reviewed-on: https://go-review.googlesource.com/18111Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent f80f6e45
...@@ -539,9 +539,12 @@ func TestTCPStress(t *testing.T) { ...@@ -539,9 +539,12 @@ func TestTCPStress(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer ln.Close() done := make(chan bool)
// Acceptor. // Acceptor.
go func() { go func() {
defer func() {
done <- true
}()
for { for {
c, err := ln.Accept() c, err := ln.Accept()
if err != nil { if err != nil {
...@@ -559,7 +562,6 @@ func TestTCPStress(t *testing.T) { ...@@ -559,7 +562,6 @@ func TestTCPStress(t *testing.T) {
}(c) }(c)
} }
}() }()
done := make(chan bool)
for i := 0; i < conns; i++ { for i := 0; i < conns; i++ {
// Client connection. // Client connection.
go func() { go func() {
...@@ -583,4 +585,6 @@ func TestTCPStress(t *testing.T) { ...@@ -583,4 +585,6 @@ func TestTCPStress(t *testing.T) {
for i := 0; i < conns; i++ { for i := 0; i < conns; i++ {
<-done <-done
} }
ln.Close()
<-done
} }
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