mirror of
https://github.com/golang/go
synced 2024-11-12 04:00:23 -07:00
exp/winfsnotify: fix data race in TestNotifyClose
Fixes #4342. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6850080
This commit is contained in:
parent
b5aa4789f9
commit
16a5934540
@ -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")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user