Skip to content

Commit

Permalink
#5 debugging failing tailer test on Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed May 28, 2019
1 parent a1cf7bd commit af0cfd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions tailer/fswatcher/fseventProducerLoop_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type keventloop struct {
done chan struct{}
}

type Kevent syscall.Kevent_t

// Terminate the kevent loop.
// If the loop hangs in syscall.Kevent(), it will keep hanging there until the next event is read.
// Therefore, after the consumer called Close(), it should interrupt the kevent() call by closing the kq descriptor.
Expand Down Expand Up @@ -86,7 +84,7 @@ func runKeventLoop(kq int) *keventloop {
return result
}

func (event Kevent) String() string {
func event2string(event syscall.Kevent_t) string {
result := make([]string, 0, 1)
if event.Fflags&syscall.NOTE_DELETE == syscall.NOTE_DELETE {
result = append(result, "NOTE_DELETE")
Expand Down
6 changes: 3 additions & 3 deletions tailer/fswatcher/fswatcher_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,20 @@ func (w *watcher) processEvent(t *fileTailer, event fsevent, log logrus.FieldLog
for _, dir = range t.watchedDirs {
if kevent.Ident == fdToInt(dir.file.Fd()) {
dirLogger = log.WithField("directory", dir.file.Name())
dirLogger.Debugf("dir event: %v", kevent)
dirLogger.Debugf("dir event: %v", event2string(kevent))
return w.processDirEvent(t, kevent, dir, dirLogger)
}
}
for _, file = range t.watchedFiles {
if kevent.Ident == fdToInt(file.file.Fd()) {
fileLogger = log.WithField("file", file.file.Name()).WithField("fd", file.file.Fd())
fileLogger.Debugf("file event: %v", kevent)
fileLogger.Debugf("file event: %v", event2string(kevent))
return w.processFileEvent(t, kevent, file, fileLogger)
}
}
// Events for unknown file descriptors are ignored. This might happen if syncFilesInDir() already
// closed a file while a pending event is still coming in.
log.Debugf("event for unknown file descriptor %v: %v", kevent.Ident, kevent)
log.Debugf("event for unknown file descriptor %v: %v", kevent.Ident, event2string(kevent))
return nil
}

Expand Down

0 comments on commit af0cfd5

Please sign in to comment.