Skip to content

Commit

Permalink
pkg/filenotify/poller: close file asap
Browse files Browse the repository at this point in the history
There is no need to wait for up to 200ms in order to close
the file descriptor once the chClose is received.

This commit might reduce the chances for occasional "The process
cannot access the file because it is being used by another process"
error on Windows, where an opened file can't be removed.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Aug 29, 2018
1 parent 88bcf15 commit dfbb64e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/filenotify/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ func (w *filePoller) sendErr(e error, chClose <-chan struct{}) error {
func (w *filePoller) watch(f *os.File, lastFi os.FileInfo, chClose chan struct{}) {
defer f.Close()
for {
time.Sleep(watchWaitTime)
select {
case <-time.After(watchWaitTime):
case <-chClose:
logrus.Debugf("watch for %s closed", f.Name())
return
default:
}

fi, err := os.Stat(f.Name())
Expand Down

0 comments on commit dfbb64e

Please sign in to comment.