Skip to content

Commit

Permalink
back out the inBuf change, shrink it
Browse files Browse the repository at this point in the history
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
  • Loading branch information
blt committed Nov 11, 2024
1 parent b922c5b commit 5f06862
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/logs/tailers/file/tailer_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ func (t *Tailer) setup(offset int64, whence int) error {
t.lastReadOffset.Store(ret)
t.decodedOffset.Store(ret)

t.inBuf = make([]byte, 4096)

return nil
}

// read lets the tailer tail the content of a file
// until it is closed or the tailer is stopped.
func (t *Tailer) read() (int, error) {
// keep reading data from file
n, err := t.osFile.Read(t.inBuf)
inBuf := make([]byte, 1024)
n, err := t.osFile.Read(inBuf)
if err != nil && err != io.EOF {
// an unexpected error occurred, stop the tailor
t.file.Source.Status().Error(err)
Expand All @@ -57,6 +56,6 @@ func (t *Tailer) read() (int, error) {
return 0, nil
}
t.lastReadOffset.Add(int64(n))
t.decoder.InputChan <- decoder.NewInput(t.inBuf[:n])
t.decoder.InputChan <- decoder.NewInput(inBuf[:n])
return n, nil
}

0 comments on commit 5f06862

Please sign in to comment.