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: fix Close()
Browse files Browse the repository at this point in the history
The code in Close() that removes the watches was not working,
because it first sets `w.closed = true` and then calls w.close(),
which starts with
```
        if w.closed {
                return errPollerClosed
	}
```

Fix by setting w.closed only after calling w.remove() for all the
files being watched.

While at it, remove the duplicated `delete(w.watches, name)` code.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Aug 30, 2018
1 parent dfbb64e commit fffa895
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/filenotify/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ func (w *filePoller) Close() error {
return nil
}

w.closed = true
for name := range w.watches {
w.remove(name)
delete(w.watches, name)
}
w.closed = true
return nil
}

Expand Down

0 comments on commit fffa895

Please sign in to comment.