-
-
Notifications
You must be signed in to change notification settings - Fork 962
Closed
Labels
Description
Hi!
Thanks a lot for this library.
Looking at the code I'm suspicious that there is a race in Close():
Lines 72 to 80 in 7f4cf4d
| // Close removes all watches and closes the events channel. | |
| func (w *Watcher) Close() error { | |
| if w.isClosed() { | |
| return nil | |
| } | |
| // Send 'close' signal to goroutine, and set the Watcher to closed. | |
| close(w.done) | |
Is it possible that two concurrent goroutines running Close() could both pass the check function w.isClosed() and then both call close(w.done)? That would result in two closes of the channel and a panic.
One solution would be to lock the w.mu at least around the w.IsClosed and close(w.done) calls.