From 0c30ec71d25fc2f9e557ca706b98b0b61ce25bbc Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 6 Oct 2026 11:32:31 +0200 Subject: [PATCH] server: reduce statewait timeout from 5s to 500ms When reading statewait with the same state value, the server now waits 500ms instead of 5 seconds before returning. This makes state polling much more responsive. --- cmd/olliesrv/server.go | 2 +- virtfs/file.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/olliesrv/server.go b/cmd/olliesrv/server.go index 3f99889..7e0b177 100644 --- a/cmd/olliesrv/server.go +++ b/cmd/olliesrv/server.go @@ -567,7 +567,7 @@ func read(root *fs.Tree, cs *connState, fc *plan9.Fcall, ctx context.Context) *p f.mu.Unlock() } cs.mu.RUnlock() - waitCtx, waitCancel := context.WithTimeout(ctx, 5*time.Second) + waitCtx, waitCancel := context.WithTimeout(ctx, 500*time.Millisecond) defer waitCancel() content, nextBase, err := entry.BlockingRead(waitCtx, base) if err != nil { diff --git a/virtfs/file.go b/virtfs/file.go index 6494252..0d31285 100644 --- a/virtfs/file.go +++ b/virtfs/file.go @@ -23,7 +23,7 @@ type File interface { BlockingRead(ctx context.Context, base string) (content []byte, nextBase string, err error) // Read-side contracts (mutually exclusive — at most one true): - // BlockingReadMode — blocks up to 5s for next value, returns it or empty, EOF on 2nd read + // BlockingReadMode — blocks up to 500ms for next value, returns it or empty, EOF on 2nd read // StreamMode — blocks indefinitely, streams data incrementally, FD lives until EOF // RdwrMode — write blocks until result produced, read returns result once BlockingReadMode() bool @@ -38,7 +38,7 @@ type fileConfig struct { WriteFn func([]byte) error CloseFn func() error BlockingReadFn func(context.Context, string) ([]byte, string, error) - BlockingRead_ bool // one-shot waiter: block 5s, return once, EOF on 2nd read + BlockingRead_ bool // one-shot waiter: block 500ms, return once, EOF on 2nd read StreamMode_ bool // indefinite stream: block forever, keep FD open Rdwr_ bool // rdwr: write blocks on write, read returns result once }