Closed vladlosev closed 7 years ago
@vladlosev Thanks for your contribution.
Thank you! The build failures seem to be caused (from looking at the stack traces) by the bug fixed in fsnotify/fsnotify#203. Unfortunately, fsnotify/fsnotify haven't had a release after that PR, and the package at gopkg.in/fsnotify.v1 doesn't have any label to update to. 😞 Maybe switch to pulling fsnotify
directly from github?
TL;DR this fixes a bug in
fsnotify.Watch
reference counting resulting intail
stopping updates after a tailed file is moved when using inotify.When
InotifyTracker.create
is called fromRemoveWatchCreate
it decrements the watch counter for the parent dir of the filename tracked, then removes the watch and bails out. But the correspondingWatchCreate
was incrementing counters for both tracked filename and its parent. Thus, the count for the filename is leaked. The followingCreate
call would find the count for the filename already at 1 and assume the watch for the filename itself is already there. Thus no watch would be created and no updates would be coming.This change moves the cleanup code into the single place and makes sure each
InotifyTracker
'sRemoveWatch
andRemoveWatchCreate
calls correctly clean-up reference counts and watches created in correspondingWatch
andWatchCreate
calls. Also adds a couple of tests to verify the fix.