Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
pkg/filenotify: poller.Add: fix fd leaks on err
Browse files Browse the repository at this point in the history
In case of errors, the file descriptor is never closed. Fix it.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Aug 29, 2018
1 parent 64b7575 commit 88bcf15
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/filenotify/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ func (w *filePoller) Add(name string) error {
}
fi, err := os.Stat(name)
if err != nil {
f.Close()
return err
}

if w.watches == nil {
w.watches = make(map[string]chan struct{})
}
if _, exists := w.watches[name]; exists {
f.Close()
return fmt.Errorf("watch exists")
}
chClose := make(chan struct{})
Expand Down

0 comments on commit 88bcf15

Please sign in to comment.