Descriptionfsnotify: fix data race on kevent buffer.
In the BSD implementation of fsnotify, the watcher's kbuf buffers a
kevent between syscall.SetKevent (which prepares the kevent) and
syscall.Kevent (which registers the kevent). The implementation intends
to protect access to kbuf, but fails to do so in addWatch and removeWatch.
This change fixes the data race by allocating a new kevent buffer for
every method invocation.
Run the following command (as suggested by nathany) to test the change on OS X:
go test -test.run=TestConcurrentRemovalOfWatch -test.cpu=1,1,1,1,1 -race
Patch Set 1 #Patch Set 2 : diff -r 19114a3ee7d5 https://code.google.com/p/go.exp/ #Patch Set 3 : diff -r 19114a3ee7d5 https://code.google.com/p/go.exp/ #Patch Set 4 : diff -r 19114a3ee7d5 https://code.google.com/p/go.exp/ #Patch Set 5 : diff -r 19114a3ee7d5 https://code.google.com/p/go.exp/ #Patch Set 6 : diff -r 19114a3ee7d5 https://code.google.com/p/go.exp/ #Patch Set 7 : diff -r 19114a3ee7d5 https://code.google.com/p/go.exp/ #MessagesTotal messages: 13
|