summaryrefslogtreecommitdiff
path: root/src/Messages.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 07:27:13 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit22fb8b6147f7fb72407af80c36d5e99e4664fea2 (patch)
tree0f5543812af5421a55d21e3bd95d929a19b48d82 /src/Messages.zig
parentb3557640d6a0a4c2c41b6e1cae3c8182a32937ca (diff)
downloadpardes-22fb8b6147f7fb72407af80c36d5e99e4664fea2.tar.gz
pardes-22fb8b6147f7fb72407af80c36d5e99e4664fea2.zip
Mount dials its peer at once and fails if none answers; a peer out of reach is said as `dial failed: <reason>`
Mount took any well-formed dial and nothing was found out until the first look through it, which then said `look: look: dial`. Mount now probes the peer (version, attach, its root) with the turn out, and fails its write, mounting nothing, when none answers; the dial errors read as words, `no answer`, `timed out`, `hung up`, and a look through a peer gone since names its path: `look: /n/peer/f: dial failed: no answer`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Messages.zig')
-rw-r--r--src/Messages.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Messages.zig b/src/Messages.zig
index c0838fb2..482ad64d 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -450,10 +450,27 @@ pub const no_pane_slots = "no space for a pane: {d} max";
pub const no_pane_room = "no space for a pane in that column: each keeps its tag and {d} rows";
/// `<operation>: <the error in words>`: FileNotFound reads "file not found".
+/// Why a peer could not be reached, in words, for an error of a 9P dial
+/// (src/9p_io.zig, Client); null for any other error.
+pub fn dialReason(err: anyerror) ?[]const u8 {
+ return switch (err) {
+ error.Dial => "no answer",
+ error.Timeout => "timed out",
+ error.Hangup => "hung up",
+ error.Botch => "protocol botch",
+ else => null,
+ };
+}
+
pub fn reportError(p: *Pardes, id: usize, operation: []const u8, err: anyerror) void {
var buf: [256]u8 = undefined;
var w = std.Io.Writer.fixed(&buf);
w.print("{s}: ", .{operation}) catch {};
+ // A peer out of reach says so, not the error's name (`dial`).
+ if (dialReason(err)) |why| {
+ w.print("dial failed: {s}", .{why}) catch {};
+ return reportFailure(p, id, w.buffered());
+ }
// Every route that opens a pane says the cap the same way.
if (err == error.NoPaneSlots or err == error.NoPaneRoom) {
if (err == error.NoPaneSlots)