tailer struct was incorrect and used incorrect channel
This commit is contained in:
Vendored
+5
-4
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user