summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/9p_io.zig')
-rw-r--r--src/9p_io.zig22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 6182ca75..7c366aa8 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -229,7 +229,9 @@ pub const Listener = struct {
if (req.op == .release and quiet) l.collectOs();
// A read with nothing yet stays parked in the engine, and the core
// keeps it to answer when what it waits on has something.
- if (reply.status == .again and req.op == .read) pardes.ctlfs.hold(core, req, conn);
+ if (reply.status == .again and req.op == .read) if (pardes.ctlfs.openOf(core, req)) |o| {
+ o.held = .{ .asker = conn, .req = req };
+ };
if (!pardes.ctlfs.changesPane(req)) return conn.reply(&reply, core.fsPayload(reply));
// The editor draws the change and performs what it asked for; when
// it asked for something -- a save, a shell, a watch -- the answer
@@ -262,8 +264,8 @@ pub const Listener = struct {
const core = l.core;
if (!core.fs.news) return;
core.fs.news = false;
- for (&core.fs.held) |*slot| {
- const held = slot.* orelse continue;
+ for (&core.fs.opens) |*o| {
+ const held = o.held orelse continue;
const conn: *Runner.Conn = @ptrCast(@alignCast(held.asker));
conn.lock();
const parked: ?bool = for (conn.engine.slots) |sl| {
@@ -272,13 +274,13 @@ pub const Listener = struct {
// Gone (flushed, answered, hung up) it is forgotten; out being
// asked again, the asking answers it.
if (parked != true) {
- if (parked == null) slot.* = null;
+ if (parked == null) o.held = null;
conn.unlock();
continue;
}
const reply = core.serveFs(held.req);
if (reply.status != .again) {
- slot.* = null;
+ o.held = null;
conn.engine.reply(&reply, core.fsPayload(reply));
}
conn.unlock();
@@ -1280,7 +1282,7 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r
l.reset(p);
try testing.expectEqual(@as(usize, 0), l.runner.count());
for (&l.conns, 0..) |conn, i| try testing.expect(!l.live(@intCast(i)) and !conn.draining);
- for (p.fs.snapshots) |snapshot| try testing.expect(snapshot.node == 0);
+ for (p.fs.opens) |o| try testing.expect(o.node == 0);
}
};
}
@@ -1409,8 +1411,8 @@ test "a held read is answered when the log has news, and a flushed one spends no
const deadline = Client.nowMs() + Client.budget_ms;
while (Client.nowMs() < deadline) {
pardes.turn.wake();
- const any = for (core.fs.held) |slot| {
- if (slot != null) break true;
+ const any = for (core.fs.opens) |o| {
+ if (o.held != null) break true;
} else false;
pardes.turn.rest();
if (any) return;
@@ -1450,8 +1452,8 @@ test "a held read is answered when the log has news, and a flushed one spends no
try testing.expect(std.mem.indexOf(u8, answered.result.read, "while held") != null);
s.drop(1);
pardes.turn.wake();
- const left = for (p.fs.held) |slot| {
- if (slot != null) break true;
+ const left = for (p.fs.opens) |o| {
+ if (o.held != null) break true;
} else false;
pardes.turn.rest();
try testing.expect(!left);