watches map[string]*watch // Map of inotify watches (key: path)
paths map[int]string // Map of watched paths (key: watch descriptor)
done chan struct{} // Channel for sending a "quit message" to the reader goroutine
- doneresp chan struct{} // Channel to respond to Close
+ doneResp chan struct{} // Channel to respond to Close
}
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
Events: make(chan Event),
Errors: make(chan error),
done: make(chan struct{}),
- doneresp: make(chan struct{}),
+ doneResp: make(chan struct{}),
}
go w.readEvents()
w.poller.wake()
// Wait for goroutine to close
- <-w.doneresp
+ <-w.doneResp
return nil
}
ok bool // For poller.wait
)
- defer close(w.doneresp)
+ defer close(w.doneResp)
defer close(w.Errors)
defer close(w.Events)
defer syscall.Close(w.fd)
defer poller.close()
oks := make(chan bool)
- kill := make(chan bool)
- defer close(kill)
+ live := make(chan bool)
+ defer close(live)
go func() {
defer close(oks)
for {
t.Fatalf("poller failed: %v", err)
}
oks <- ok
- if !<-kill {
+ if !<-live {
return
}
}
t.Fatalf("expected true")
}
tfd.get(t)
- kill <- true
+ live <- true
// Try a wakeup
select {
if <-oks {
t.Fatalf("expected false")
}
- kill <- true
+ live <- true
// Try a close
select {