Skip to content

Commit

Permalink
vm: mount: improve file latency check
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft committed Mar 25, 2023
1 parent f37dd6a commit 083d203
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions daemon/process/inotify/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,24 @@ func doWatch(dirs []string, fileMap map[string]time.Time, changed chan<- modTime
currentTime, ok := fileMap[path]
newTime := info.ModTime()

if ok && newTime.After(currentTime.Add(time.Millisecond*500)) {
go func(path string) {
if !ok {
fileMap[path] = newTime
return nil
}

// only respond to files we last updated >500ms ago
if newTime.After(currentTime.Add(time.Millisecond * 500)) {

// send inotify event
go func(path string, currentTime, newTime time.Time) {
logrus.Tracef("changed file mtime %v->%v: %s", currentTime, newTime, path)
changed <- modTime{path: path, FileMode: info.Mode()}
}(path)
}(path, currentTime, newTime)

// prevent further events for the next 500ms
fileMap[path] = newTime
}

fileMap[path] = newTime
return nil
})

Expand Down

0 comments on commit 083d203

Please sign in to comment.