diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-13 10:05:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-13 10:05:47 +0200 |
| commit | 6c3bc11f736040a09fd839832a6be01e434e8aab (patch) | |
| tree | 6b856c2f79d2f75ccd8ba89c638ee18839b4d061 /internal/io/fs/readfile_processor_optimized.go | |
| parent | a5a405d79fe3d9e0c6ea081b425d36bd67d8671d (diff) | |
Stop stale query work promptly on generation cancel
Diffstat (limited to 'internal/io/fs/readfile_processor_optimized.go')
| -rw-r--r-- | internal/io/fs/readfile_processor_optimized.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/io/fs/readfile_processor_optimized.go b/internal/io/fs/readfile_processor_optimized.go index 2e880e7..1e553ee 100644 --- a/internal/io/fs/readfile_processor_optimized.go +++ b/internal/io/fs/readfile_processor_optimized.go @@ -8,6 +8,7 @@ import ( "os" "time" + "github.com/mimecast/dtail/internal/ctxutil" "github.com/mimecast/dtail/internal/io/dlog" "github.com/mimecast/dtail/internal/io/line" "github.com/mimecast/dtail/internal/io/pool" @@ -346,6 +347,8 @@ func (f *readFile) tailWithProcessorOptimized(ctx context.Context, fd *os.File, return err } + waitForMoreData := true + // EOF handling select { case <-ctx.Done(): @@ -354,8 +357,12 @@ func (f *readFile) tailWithProcessorOptimized(ctx context.Context, fd *os.File, if isTruncated, err := f.truncated(fd); isTruncated { return err } - case <-time.After(100 * time.Millisecond): - // Continue reading after a short delay + waitForMoreData = false + default: + } + + if waitForMoreData && !ctxutil.Sleep(ctx, 100*time.Millisecond) { + return nil } } |
