Browse code

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>

Kir Kolyshkin authored on 2018/08/30 14:11:42
Showing 1 changed files
... ...
@@ -115,11 +115,10 @@ func (w *filePoller) Close() error {
115 115
 		return nil
116 116
 	}
117 117
 
118
-	w.closed = true
119 118
 	for name := range w.watches {
120 119
 		w.remove(name)
121
-		delete(w.watches, name)
122 120
 	}
121
+	w.closed = true
123 122
 	return nil
124 123
 }
125 124