Skip to content

Commit

Permalink
net: fix race in TestTCPStress
Browse files Browse the repository at this point in the history
Fixes #13704.

Change-Id: I7afef5058fa88b0de41213cf46219b684369f47f
Reviewed-on: https://go-review.googlesource.com/18111
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
cixtor committed Dec 22, 2015
1 parent f80f6e4 commit 11ac72a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/net/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -559,7 +562,6 @@ func TestTCPStress(t *testing.T) {
}(c)
}
}()
done := make(chan bool)
for i := 0; i < conns; i++ {
// Client connection.
go func() {
Expand All @@ -583,4 +585,6 @@ func TestTCPStress(t *testing.T) {
for i := 0; i < conns; i++ {
<-done
}
ln.Close()
<-done
}

0 comments on commit 11ac72a

Please sign in to comment.