From cca47d63c3ba774cb4de6f76603ba6edc5b475fe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 20:46:28 -0300 Subject: fs: a backend can keep a parked request by ticket and answer it later, and a clunk interrupts what is parked on its fid A backend holding a read that has nothing yet had to find its park by walking the engine's slots and matching a tag. Now Conn.hold() answers .again and returns a Ticket (slot and that park's sequence number); Conn.waiting() says whether that very park still waits, and Conn.answerWith() answers it with what a producer makes, asking the producer only while it waits and under the same lock, the way lib9p lets a server keep a Req and respond() later, so a consuming answer is never spent on a flushed request. The sequence number counts on across the connections a runner slot serves (initIn keeps it), so a ticket of one never names a park of the next. A clunk or remove fails everything parked on its fid with EINTR first, so no slot outlives its fid to be retried with a released handle or answered to a fid of the same number walked anew; retry's check for a vanished fid is gone with it. 9ns maps acme's "shut down" to EIO. Co-Authored-By: Claude Opus 5.5 --- docs/design.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'docs/design.md') diff --git a/docs/design.md b/docs/design.md index 702315b..e8805e5 100644 --- a/docs/design.md +++ b/docs/design.md @@ -101,7 +101,14 @@ round, oldest first, until it completes; a parked write keeps a copy of its data up to `park_data_max` bytes. Any other operation answering `again`, or a park with no free slot, fails with EAGAIN. Tflush answers a parked request's tag with EINTR before its Rflush and drops the slot; a flush of an -unknown tag is just Rflush. `hangup()` marks every open fid orphaned and +unknown tag is just Rflush. A clunk or remove of a fid does the same to +everything parked on it first, so no slot outlives its fid. Instead of +waiting to be retried, a backend may keep a parked request and answer it +itself (lib9p's kept Req): `ticket()` names the park by its slot and that +park's sequence number, `waiting()` says whether it still waits (not +flushed, clunked, hung up or out being retried), and `answer()` answers it +only then, so a tag a client reuses after a flush is never answered with +what was meant for the old one. `hangup()` marks every open fid orphaned and `next()` then yields the release each one owes before anything else, so a dropped connection still pays the backend; a Tversion does the same before negotiating. @@ -157,7 +164,14 @@ the connection's task with the engine unlocked and answers with engine over between `Conn.lock()` and `Conn.unlock()`, drives `next()`, `retry()` and `reply()` itself and calls `Conn.flush()` so the connection task sends what that produced (the editor answers on its own thread this -way). `opened` and `closed` bracket a slot's life; `Conn.user` is the +way). `Conn.hold()` answers `.again` and returns the park's ticket; +`Conn.waiting()` says whether it still waits, and `Conn.answerWith()` +answers it later from anywhere with what a producer makes, asking the +producer only while the park still waits and under the same lock, so an +answer that consumes (a record off a queue) is never spent on a flushed +request. The engine's sequence number counts on across the connections a +slot serves (`initIn` keeps it), so a ticket of one never names a park of +the next. `opened` and `closed` bracket a slot's life; `Conn.user` is the application's. Wake-up is explicit. Each connection has a flag word and an `Io.Event`; the -- cgit v1.3