Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Oct 5, 2020
1 parent 1749fe9 commit a1510fa
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions filebeat/input/filestream/filestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (f *logFile) startFileMonitoringIfNeeded() {

if f.closeAfterInterval > 0 {
f.tg.Go(func(ctx unison.Canceler) error {
f.closeIfInactive(ctx)
f.periodicStateCheck(ctx)
return nil
})
}
Expand All @@ -173,7 +173,7 @@ func (f *logFile) closeIfTimeout(ctx unison.Canceler) {
}

func (f *logFile) periodicStateCheck(ctx unison.Canceler) {
ticker := time.NewTicker(f.close)
ticker := time.NewTicker(f.checkInterval)
defer ticker.Stop()

for {
Expand All @@ -185,15 +185,13 @@ func (f *logFile) periodicStateCheck(ctx unison.Canceler) {
f.cancelReading()
return
}

}
}
}

func (f *logFile) shouldBeClosed() bool {
if f.closeIfInactive {
age := time.Since(f.lastTimeRead)
if age > f.closeInactive {
if f.closeInactive > 0 {
if time.Since(f.lastTimeRead) > f.closeInactive {
return true
}
}
Expand Down Expand Up @@ -228,6 +226,15 @@ func (f *logFile) shouldBeClosed() bool {
return false
}

func isSameFile(path string, info os.FileInfo) bool {
fileInfo, err := os.Stat(path)
if err != nil {
return false
}

return os.SameFile(fileInfo, info)
}

// errorChecks determines the cause for EOF errors, and how the EOF event should be handled
// based on the config options.
func (f *logFile) errorChecks(err error) error {
Expand Down

0 comments on commit a1510fa

Please sign in to comment.