Fix watchForLockfileContention memory leak

This commit is contained in:
Shiming Zhang 2021-03-17 15:04:58 +08:00
parent 1dce8985a7
commit a3d337491f

View File

@ -29,6 +29,7 @@ func watchForLockfileContention(path string, done chan struct{}) error {
} }
if err = watcher.AddWatch(path, inotify.InOpen|inotify.InDeleteSelf); err != nil { if err = watcher.AddWatch(path, inotify.InOpen|inotify.InDeleteSelf); err != nil {
klog.ErrorS(err, "Unable to watch lockfile") klog.ErrorS(err, "Unable to watch lockfile")
watcher.Close()
return err return err
} }
go func() { go func() {
@ -39,6 +40,7 @@ func watchForLockfileContention(path string, done chan struct{}) error {
klog.ErrorS(err, "inotify watcher error") klog.ErrorS(err, "inotify watcher error")
} }
close(done) close(done)
watcher.Close()
}() }()
return nil return nil
} }