We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bfeb1da commit 45a978cCopy full SHA for 45a978c
agent/agentcontainers/watcher/noop.go
@@ -12,7 +12,9 @@ func NewNoop() Watcher {
12
}
13
14
type noopWatcher struct {
15
- closed chan struct{}
+ mu synx.Mutex
16
+ closed bool
17
+ done chan struct{}
18
19
20
func (*noopWatcher) Add(string) error {
@@ -27,12 +29,18 @@ func (n *noopWatcher) Next(ctx context.Context) (*fsnotify.Event, error) {
27
29
select {
28
30
case <-ctx.Done():
31
return nil, ctx.Err()
- case <-n.closed:
32
+ case <-n.done:
33
return nil, xerrors.New("watcher closed")
34
35
36
37
func (n *noopWatcher) Close() error {
- close(n.closed)
38
+ n.mu.Lock()
39
+ defer n.mu.Unlock()
40
+ if n.closed {
41
+ return nil
42
+ }
43
+ n.closed = true
44
+ close(n.done)
45
return nil
46
0 commit comments