Merge pull request #100326 from wzshiming/fix/memory-leak

Fix watchForLockfileContention memory leak
This commit is contained in:
Kubernetes Prow Robot 2021-05-07 13:31:16 -07:00 committed by GitHub
commit 10b09e8a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
} }