pkg/filenotify: poller.Add: fix fd leaks on err
In case of errors, the file descriptor is never closed. Fix it. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> (cherry picked from commit 88bcf1573ca2eaffc15da346a1651a3749567554) Upstream-commit: 7be43586af6824c1e55cb502d9d2bab45c9b4505 Component: engine
This commit is contained in:
@ -54,6 +54,7 @@ func (w *filePoller) Add(name string) error {
|
||||
}
|
||||
fi, err := os.Stat(name)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
@ -61,6 +62,7 @@ func (w *filePoller) Add(name string) error {
|
||||
w.watches = make(map[string]chan struct{})
|
||||
}
|
||||
if _, exists := w.watches[name]; exists {
|
||||
f.Close()
|
||||
return fmt.Errorf("watch exists")
|
||||
}
|
||||
chClose := make(chan struct{})
|
||||
|
||||
Reference in New Issue
Block a user