Skip to content

Commit

Permalink
We need the done chan for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Aug 1, 2022
1 parent 39a2d75 commit adf163d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
type Watcher struct {
Events chan Event
Errors chan error
done chan bool

kq int // File descriptor (as returned by the kqueue() syscall).
closepipe [2]int // Pipe used for closing.
Expand Down Expand Up @@ -87,6 +88,7 @@ func (w *Watcher) Close() error {
}

// Send "quit" message to the reader goroutine.
w.done <- true
unix.Close(w.closepipe[1])

return nil
Expand Down Expand Up @@ -314,7 +316,8 @@ func (w *Watcher) readEvents() {
select {
case w.Errors <- err:
case <-w.done:
break loop
closed = true
continue
}
continue
}
Expand Down Expand Up @@ -360,7 +363,8 @@ func (w *Watcher) readEvents() {
select {
case w.Events <- event:
case <-w.done:
break loop
closed = true
continue
}
}

Expand Down

0 comments on commit adf163d

Please sign in to comment.