]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix race in TestChanSendBarrier
authorRuss Cox <rsc@golang.org>
Mon, 13 Jul 2015 19:23:59 +0000 (15:23 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 13 Jul 2015 19:42:20 +0000 (19:42 +0000)
Fixes race detector build.

Change-Id: I8bdc78d57487580e6b5b8c415df4653a1ba69e37
Reviewed-on: https://go-review.googlesource.com/12087
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/chanbarrier_test.go

index c48fd3c9658f24eb64271f9c214771af2fa72988..770b850f8749f04f008d5f8a947de14b9e4d6d93 100644 (file)
@@ -54,6 +54,7 @@ func TestChanSendBarrier(t *testing.T) {
 
 func testChanSendBarrier(useSelect bool) {
        var wg sync.WaitGroup
+       var globalMu sync.Mutex
        outer := 100
        inner := 100000
        if testing.Short() {
@@ -73,7 +74,9 @@ func testChanSendBarrier(useSelect bool) {
                                }
                                garbage = make([]byte, 1<<10)
                        }
+                       globalMu.Lock()
                        global = garbage
+                       globalMu.Unlock()
                }()
        }
        wg.Wait()