From 21c28e45663511d9c2f529f2a39bc0855a9c245e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 29 Aug 2018 22:11:42 -0700 Subject: [PATCH] pkg/filenotify/poller: fix Close() 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 (cherry picked from commit fffa8958d00860b4e3563327a2cc6836a12d4ba9) Upstream-commit: 4e2dbfa1af48191126b0910b9463bf94d8371886 Component: engine --- components/engine/pkg/filenotify/poller.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/engine/pkg/filenotify/poller.go b/components/engine/pkg/filenotify/poller.go index 8f6c310e1e..6161d4ab73 100644 --- a/components/engine/pkg/filenotify/poller.go +++ b/components/engine/pkg/filenotify/poller.go @@ -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 }