diff --git a/watcher.go b/watcher.go index 14bef6d..facc962 100644 --- a/watcher.go +++ b/watcher.go @@ -399,6 +399,13 @@ func (w *watcher) loop() { var pending []*aiocb for { + // Prevents execution of the timer + select { + case <-w.die: + return + default: + } + select { case <-w.chPendingNotify: // copy from w.pending to local pending @@ -445,7 +452,6 @@ func (w *watcher) loop() { } w.gc = w.gc[:0] w.gcMutex.Unlock() - case <-w.die: return }