Skip to content

Commit

Permalink
fix send on closed channel
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed Dec 27, 2018
1 parent a585b9c commit ad188fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tailer/fswatcher/fswatcher_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ func Run(globs []string, readall bool, failOnMissingFile bool) (FSWatcher, error

for { // kevent consumer loop
select {
case <-w.done:
return
case event := <-keventProducerLoop.events:
w.processEvent(event, logger2)
case err := <-keventProducerLoop.errors:
select {
case w.errors <- err:
case <-w.done:
case w.errors <- err:
}
return
case <-w.done:
return
}
}
}()
Expand Down Expand Up @@ -352,9 +352,9 @@ func (w *watcher) readNewLines(file *fileWithReader, log logrus.FieldLogger) {
}
log.Debugf("read line %q", line)
select {
case w.lines <- Line{Line: line, File: file.file.Name()}:
case <-w.done:
return
case w.lines <- Line{Line: line, File: file.file.Name()}:
}
}
}
Expand All @@ -368,8 +368,8 @@ OUTER:
}
}
select {
case w.errors <- NewError(FileNotFound, fmt.Sprintf("%v: no such file", glob), nil):
case <-w.done:
case w.errors <- NewError(FileNotFound, fmt.Sprintf("%v: no such file", glob), nil):
}
w.Close()
return true
Expand Down Expand Up @@ -478,8 +478,8 @@ func contains(list []*fileWithReader, f *fileWithReader) bool {

func (w *watcher) errorClose(cause error, format string, a ...interface{}) {
select {
case w.errors <- NewError(NotSpecified, fmt.Sprintf(format, a...), cause):
case <-w.done:
case w.errors <- NewError(NotSpecified, fmt.Sprintf(format, a...), cause):
}
w.Close()
}
Expand Down
4 changes: 2 additions & 2 deletions tailer/fswatcher/keventloop_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ func runKeventLoop(kq int) *keventloop {
return
} else if err != nil {
select {
case l.errors <- NewError(NotSpecified, "kevent system call failed", err):
case <-l.done:
case l.errors <- NewError(NotSpecified, "kevent system call failed", err):
}
return
} else {
for i = 0; i < n; i++ {
select {
case l.events <- eventBuf[i]:
case <-l.done:
return
case l.events <- eventBuf[i]:
}
}
}
Expand Down

0 comments on commit ad188fd

Please sign in to comment.