summaryrefslogtreecommitdiff
path: root/internal/server/handlers/readcommand.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-02 10:31:26 +0200
committerPaul Buetow <paul@buetow.org>2026-03-02 10:31:26 +0200
commit3002bdcaa4ec22aa46b6c98eefda2f926dfff618 (patch)
tree43cc06e2bd690b41b33a3b56735823affed541bb /internal/server/handlers/readcommand.go
parent29e50d7b6ebb9e6c59d079ef5b7551b1acd950fb (diff)
handlers: use turbo EOF acknowledgement instead of sleep heuristic
Diffstat (limited to 'internal/server/handlers/readcommand.go')
-rw-r--r--internal/server/handlers/readcommand.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/server/handlers/readcommand.go b/internal/server/handlers/readcommand.go
index ad2b87f..6078e37 100644
--- a/internal/server/handlers/readcommand.go
+++ b/internal/server/handlers/readcommand.go
@@ -142,13 +142,19 @@ func (r *readCommand) readFiles(ctx context.Context, ltx lcontext.LContext,
// Signal EOF by closing the channel, but only once.
r.server.SignalTurboEOF()
- // Wait to ensure all data is transmitted
- // This is especially important when files are queued due to concurrency limits
- // In serverless mode, data is written directly to stdout, so no wait is needed
+ // Wait for an explicit reader acknowledgement instead of timing guesses.
if !r.server.Serverless() {
- waitTime := r.server.TurboEOFWaitDuration(len(paths))
- dlog.Server.Debug(r.server.LogContext(), "Waiting for data transmission", "duration", waitTime)
- time.Sleep(waitTime)
+ timeout := r.server.TurboEOFAckTimeout()
+ if r.server.WaitForTurboEOFAck(timeout) {
+ dlog.Server.Debug(r.server.LogContext(), "Turbo EOF acknowledged")
+ } else {
+ dlog.Server.Warn(
+ r.server.LogContext(),
+ "Timeout waiting for turbo EOF acknowledgement",
+ "timeout", timeout,
+ "remainingTurbo", r.server.TurboChannelLen(),
+ )
+ }
}
}
}