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.
This commit is contained in:
parent
3655b16b4b
commit
0c30ec71d2
|
|
@ -567,7 +567,7 @@ func read(root *fs.Tree, cs *connState, fc *plan9.Fcall, ctx context.Context) *p
|
||||||
f.mu.Unlock()
|
f.mu.Unlock()
|
||||||
}
|
}
|
||||||
cs.mu.RUnlock()
|
cs.mu.RUnlock()
|
||||||
waitCtx, waitCancel := context.WithTimeout(ctx, 5*time.Second)
|
waitCtx, waitCancel := context.WithTimeout(ctx, 500*time.Millisecond)
|
||||||
defer waitCancel()
|
defer waitCancel()
|
||||||
content, nextBase, err := entry.BlockingRead(waitCtx, base)
|
content, nextBase, err := entry.BlockingRead(waitCtx, base)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type File interface {
|
||||||
BlockingRead(ctx context.Context, base string) (content []byte, nextBase string, err error)
|
BlockingRead(ctx context.Context, base string) (content []byte, nextBase string, err error)
|
||||||
|
|
||||||
// Read-side contracts (mutually exclusive — at most one true):
|
// 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
|
// StreamMode — blocks indefinitely, streams data incrementally, FD lives until EOF
|
||||||
// RdwrMode — write blocks until result produced, read returns result once
|
// RdwrMode — write blocks until result produced, read returns result once
|
||||||
BlockingReadMode() bool
|
BlockingReadMode() bool
|
||||||
|
|
@ -38,7 +38,7 @@ type fileConfig struct {
|
||||||
WriteFn func([]byte) error
|
WriteFn func([]byte) error
|
||||||
CloseFn func() error
|
CloseFn func() error
|
||||||
BlockingReadFn func(context.Context, string) ([]byte, string, 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
|
StreamMode_ bool // indefinite stream: block forever, keep FD open
|
||||||
Rdwr_ bool // rdwr: write blocks on write, read returns result once
|
Rdwr_ bool // rdwr: write blocks on write, read returns result once
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue