summaryrefslogtreecommitdiff
path: root/src/ninep/events.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/events.zig')
-rw-r--r--src/ninep/events.zig15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index fb49e41b..bd53bcd9 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -89,6 +89,13 @@ pub const Queue = struct {
}
};
+/// What the next read would answer, which is the size a stat reports: a
+/// client can see there is something waiting without parking on it.
+pub fn pending(q: *const Queue) u64 {
+ const record = q.peek() orelse return 0;
+ return record.len;
+}
+
/// One record per read; `.again` parks the read until a record arrives.
pub fn readQueue(p: *Pardes, req: Req, q: *Queue) Reply {
const record = q.peek() orelse return .{ .tag = req.tag, .status = .again };
@@ -461,7 +468,7 @@ test "a pane deleted while its event file is open leaves no suppression behind"
const b = call(p, .{ .tag = 19, .op = .open, .node = event });
try testing.expectEqual(@as(u16, 2), p.fs.listeners);
- _ = wr(p, Node.of(serial, .ctl), "exec Del\n");
+ _ = wr(p, Node.of(serial, .exec), "Del\n");
try testing.expect(p.paneBySerial(serial) == null);
try testing.expectEqual(@as(u16, 0), p.fs.listeners);
@@ -471,7 +478,7 @@ test "a pane deleted while its event file is open leaves no suppression behind"
try testing.expectEqual(E.NOENT, rd(p, event, 0, 64).errno());
try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .body), 0, 64).errno());
- try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .ctl), "clean\n").errno());
+ try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .dirty), "0\n").errno());
try testing.expectEqual(E.NOENT, call(p, .{ .tag = 22, .op = .open, .node = event }).errno());
}
@@ -535,7 +542,7 @@ test "the log parks until a pane is created, renamed, saved or deleted" {
try std.fmt.bufPrint(&expected, "rename {d} /tmp/logged.txt\n", .{serial}),
rd(p, log, 0, 4096).bytes,
);
- const saving = wr(p, Node.of(serial, .ctl), "exec Save\n");
+ const saving = wr(p, Node.of(serial, .exec), "Save\n");
try testing.expectEqual(Status.ok, saving.reply.status);
try testing.expect(saving.saved);
p.perform(.{ .save_file = .{ .pane = @intCast(id) } });
@@ -543,7 +550,7 @@ test "the log parks until a pane is created, renamed, saved or deleted" {
try std.fmt.bufPrint(&expected, "save {d} /tmp/logged.txt\n", .{serial}),
rd(p, log, 0, 4096).bytes,
);
- try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Del\n").reply.status);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "Del\n").reply.status);
try testing.expectEqualStrings(
try std.fmt.bufPrint(&expected, "del {d} /tmp/logged.txt\n", .{serial}),
rd(p, log, 0, 4096).bytes,