]> Cypherpunks repositories - gostls13.git/commitdiff
exp/winfsnotify: fix data race in TestNotifyClose
authorAlex Brainman <alex.brainman@gmail.com>
Wed, 28 Nov 2012 06:01:22 +0000 (17:01 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Wed, 28 Nov 2012 06:01:22 +0000 (17:01 +1100)
Fixes #4342.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6850080

src/pkg/exp/winfsnotify/winfsnotify_test.go

index 4a1929a839715c01bd865124f3fc9b3a6a47ca68..a0bd4327fb5ebf958ca143b531323c17bdd44e26 100644 (file)
@@ -9,6 +9,7 @@ package winfsnotify
 import (
        "io/ioutil"
        "os"
+       "sync/atomic"
        "testing"
        "time"
 )
@@ -105,14 +106,14 @@ func TestNotifyClose(t *testing.T) {
        watcher, _ := NewWatcher()
        watcher.Close()
 
-       done := false
+       var done int32
        go func() {
                watcher.Close()
-               done = true
+               atomic.StoreInt32(&done, 1)
        }()
 
        time.Sleep(50 * time.Millisecond)
-       if !done {
+       if atomic.LoadInt32(&done) == 0 {
                t.Fatal("double Close() test failed: second Close() call didn't return")
        }