1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2018-08-29 22:11:42 -07:00
parent dfbb64ea7d
commit fffa8958d0

View file

@ -115,11 +115,10 @@ func (w *filePoller) Close() error {
return nil return nil
} }
w.closed = true
for name := range w.watches { for name := range w.watches {
w.remove(name) w.remove(name)
delete(w.watches, name)
} }
w.closed = true
return nil return nil
} }