diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-08 09:26:57 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-08 09:26:57 +0200 |
| commit | b338ad35897117e38ad9a72dfe5cce5d0d05d6ba (patch) | |
| tree | 2b091c45dd1bc124d64fe5693a9ec4e6199471b9 | |
| parent | 8b2635cd100cf9dc217ee9b472a02999a7d3fdf4 (diff) | |
task: harden truncate signal lifecycle in processor readers (task 372)
| -rw-r--r-- | internal/io/fs/readfile_processor.go | 8 | ||||
| -rw-r--r-- | internal/io/fs/readfile_processor_optimized.go | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/internal/io/fs/readfile_processor.go b/internal/io/fs/readfile_processor.go index 1658541..4e636a4 100644 --- a/internal/io/fs/readfile_processor.go +++ b/internal/io/fs/readfile_processor.go @@ -29,10 +29,12 @@ func (f *readFile) StartWithProcessor(ctx context.Context, ltx lcontext.LContext return err } + truncateCtx, cancelTruncate := context.WithCancel(ctx) + defer cancelTruncate() + truncate := make(chan struct{}) - defer close(truncate) - go f.periodicTruncateCheck(ctx, truncate) + go f.periodicTruncateCheck(truncateCtx, truncate) // Process file with direct callbacks instead of channels err = f.readWithProcessor(ctx, fd, reader, truncate, ltx, processor, re) @@ -283,4 +285,4 @@ func (fp *filteringProcessor) processWithContext(rawLine *bytes.Buffer, lineNum } return nil -}
\ No newline at end of file +} diff --git a/internal/io/fs/readfile_processor_optimized.go b/internal/io/fs/readfile_processor_optimized.go index 716fb1f..96d5a16 100644 --- a/internal/io/fs/readfile_processor_optimized.go +++ b/internal/io/fs/readfile_processor_optimized.go @@ -226,7 +226,6 @@ func (f *readFile) StartWithProcessorOptimized(ctx context.Context, ltx lcontext defer cancelTruncate() truncate := make(chan struct{}) - defer close(truncate) go f.periodicTruncateCheck(truncateCtx, truncate) @@ -368,4 +367,4 @@ func (f *readFile) tailWithProcessorOptimized(ctx context.Context, fd *os.File, default: } } -}
\ No newline at end of file +} |
