tailer struct was incorrect and used incorrect channel

This commit is contained in:
2026-05-18 01:14:57 -06:00
parent 66c6ed7793
commit 9b0610b879
5 changed files with 21 additions and 8 deletions
+5 -4
View File
@@ -2,31 +2,32 @@ package cache
import (
"io"
"log/slog"
"os"
"time"
)
type tailer struct {
f *os.File
done <-chan struct{}
flight *inFlight
}
func (t *tailer) Read(p []byte) (int, error) {
for {
n, err := t.f.Read(p)
slog.Debug("tailer read", "n", n, "err", err)
if n > 0 {
return n, nil
}
if err == io.EOF {
select {
case <-t.done:
case <-t.flight.done:
if t.flight.err != nil {
return 0, t.flight.err
}
return t.f.Read(p) // send remainiing bytes
default:
time.Sleep(50 * time.Millisecond)
case <-time.After(50 * time.Millisecond):
slog.Debug("tailer waiting for more data")
continue
}
}