diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-09 03:29:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-09 03:30:37 -0300 |
| commit | 446292e15d56c9c248dae5d6fde1be3a83ade82e (patch) | |
| tree | 859d8be8a92a18011034e614324fa1af5c99139e /src/ninep/events.zig | |
| parent | aabbccba49772cf73c7e35ae470245e9fda9d6ff (diff) | |
| download | pardes-446292e15d56c9c248dae5d6fde1be3a83ade82e.tar.gz pardes-446292e15d56c9c248dae5d6fde1be3a83ade82e.zip | |
idioms: the 9P tree's swallows decided: a directory read stages every entry or answers ENOMEM (stageDirent and sources.stage return error{OutOfMemory}, readdir's entries made by stageDir, an /os listing whose buffer fills ends there), a pane's tag read through tagOf fails by name (a read or an event write answers ENOMEM, a stat's length and ctl's line say 0), a pane that cannot close (removePane's nine swallowing callers) and a /pager text that cannot go in (fillClosedPagers) are said on their pane, and Queue.push says once why a lost record is not said
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/events.zig')
| -rw-r--r-- | src/ninep/events.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 20cb4e6e..77a4e35f 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -39,6 +39,9 @@ pub const Queue = struct { q.head = 0; } + /// With no memory for it the record is lost, as one pushed out of a + /// full ring is: its callers have nowhere to say so (the log is one of + /// these rings, and an event or pty reader is told by what it reads). pub fn push(q: *Queue, gpa: std.mem.Allocator, record: []const u8) void { if (record.len > std.math.maxInt(u32)) return; while (q.buf.items.len - q.head + record.len + 4 > q.cap) { @@ -712,7 +715,7 @@ pub fn writeEvent(p: *Pardes, asked: Req, id: usize) Reply { const serial = pane0.serial; { const body = pane_files.bodyOf(pane0); - const tag = pane_files.tagOf(p, pane0); + const tag = pane_files.tagOf(p, pane0) catch return Reply.fail(req.tag, E.NOMEM); var check: EventReader = .{ .data = req.data }; while (check.next()) |r| { // Who made it: E, F, K or M, as acme's records say. @@ -738,7 +741,7 @@ pub fn writeEvent(p: *Pardes, asked: Req, id: usize) Reply { while (run.next()) |r| { const live = p.paneBySerial(serial) orelse break; const pane = p.panes[live].?; - const whole = if (r.action.onTag()) pane_files.tagOf(p, pane) else pane_files.bodyOf(pane); + const whole = if (r.action.onTag()) pane_files.tagOf(p, pane) catch return Reply.fail(req.tag, E.NOMEM) else pane_files.bodyOf(pane); const lo = @min(@as(usize, r.q0), whole.len); const hi = @max(lo, @min(@as(usize, r.q1), whole.len)); // An empty range with no text is a click at that point: expanded as |
