diff options
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 |
