FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
exp/winfsnotify: fix data race in TestNotifyClose

Fixes issue 4342.

Please review this at http://codereview.appspot.com/6850080/

Affected files:
M src/pkg/exp/winfsnotify/winfsnotify_test.go


Index: src/pkg/exp/winfsnotify/winfsnotify_test.go
===================================================================
--- a/src/pkg/exp/winfsnotify/winfsnotify_test.go
+++ b/src/pkg/exp/winfsnotify/winfsnotify_test.go
@@ -9,6 +9,7 @@
import (
"io/ioutil"
"os"
+ "sync/atomic"
"testing"
"time"
)
@@ -105,14 +106,14 @@
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")
}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 20, '12 at 5:19a
activeNov 28, '12 at 6:01a
posts3
users2
websitegolang.org

2 users in discussion

Alex Brainman: 2 posts Russ Cox: 1 post

People

Translate

site design / logo © 2022 Grokbase