]> go.fuhry.dev Git - fsnotify.git/commit
inotify: fix race in Close() (#465)
authorMartin Tournoij <martin@arp242.net>
Fri, 22 Jul 2022 05:22:49 +0000 (07:22 +0200)
committerGitHub <noreply@github.com>
Fri, 22 Jul 2022 05:22:49 +0000 (07:22 +0200)
commit7fe2936a4fe9f4eda1299c36dda9e12d4bcab6c7
tree708c314c94d4fe645103ecd7c1db987ce3e31992
parent35b637890e3868e1f322b2b79cc187e6eb1e28f2
inotify: fix race in Close() (#465)

Would sometimes fail with:

panic: close of closed channel

goroutine 204 [running]:
github.com/fsnotify/fsnotify.(*Watcher).Close(0xc0003e6410)
         /home/martin/code/Golib/fsnotify/inotify.go:82 +0x66
created by github.com/fsnotify/fsnotify.TestCloseRace
         /home/martin/code/Golib/fsnotify/integration_test.go:1256 +0x1a5
exit status 2

Because isClosed() might return "false" for two goroutines, and then
they will both try to close it, resulting in the panic.

Fixes #367
inotify.go
inotify_test.go
integration_test.go