Commit 1fa0a8ce authored by Mikio Hara's avatar Mikio Hara

runtime: fix data race in BenchmarkChanPopular

Fixes #11014.

Change-Id: I9a18dacd10564d3eaa1fea4d77f1a48e08e79f53
Reviewed-on: https://go-review.googlesource.com/10563Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 71cc6755
......@@ -898,6 +898,8 @@ func BenchmarkChanPopular(b *testing.B) {
const n = 1000
c := make(chan bool)
var a []chan bool
var wg sync.WaitGroup
wg.Add(n)
for j := 0; j < n; j++ {
d := make(chan bool)
a = append(a, d)
......@@ -908,6 +910,7 @@ func BenchmarkChanPopular(b *testing.B) {
case <-d:
}
}
wg.Done()
}()
}
for i := 0; i < b.N; i++ {
......@@ -915,4 +918,5 @@ func BenchmarkChanPopular(b *testing.B) {
d <- true
}
}
wg.Wait()
}
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