hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.71k stars 503 forks source link

deadlock when watching files with inotify with recent fsnotify changes #75

Closed tsuna closed 8 years ago

tsuna commented 8 years ago

Due to fsnotify/fsnotify#73 the logic in watch/inotify_tracker.go is now subject to frequent deadlocks: all you need is to try to Cleanup() a Tail object while fsnotify is trying to send a notification. With the recent fsnotify changes, Cleanup() ends up making InotifyTracker.run() call shared.removeWatch(winfo), which then calls shared.watcher.Remove(fname), which then waits until the main inotify loop is done handling the IN_IGNORED event indicating that the file is no longer being watched by the kernel. But for the inotify loop to handle this event, it needs to not be stuck on trying to send an event. Hence the deadlock if it's already in the process of trying to send an event.