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, 20 insertions, 2 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index d1b2099c..0eaa2d7e 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -1542,6 +1542,11 @@ test "a change waits while the editor is out mid-step, a read does not, and the
try testing.expectEqualStrings("after\n", pane.file.?.content);
}
+test "a connection holds up to 128 reads, and the next is refused in words" {
+ try testing.expectEqual(@as(usize, 128), ninep.max_held);
+ if (comptime supported) try testing.expectEqualStrings("too many reads waiting: 128", Runner.Engine.e_waiting);
+}
+
test "a held read is answered when the log has news, and a flushed one spends nothing" {
if (comptime !supported) return error.SkipZigTest;
const gpa = testing.allocator;
@@ -1808,7 +1813,17 @@ pub const Client = struct {
var sock_buf: [sun_path_len]u8 = undefined;
const sock = try resolve(&sock_buf, dial);
var remote: RemoteError = .{};
- return fetchBytes(gpa, sock, names[0..n], &remote, null, display_path, @min(max_bytes, limits.max_file_bytes));
+ return fetchBytes(gpa, sock, names[0..n], &remote, null, display_path, @min(max_bytes, limits.max_file_bytes)) catch |err| {
+ if (err == error.Remote) said = remote;
+ return err;
+ };
+ }
+
+ /// The peer's own words for the last error.Remote a read or write here
+ /// got (its Rerror), for a caller that says why.
+ var said: RemoteError = .{};
+ pub fn lastSaid() []const u8 {
+ return said.buf[0..said.len];
}
/// Whether a peer answers at `dial`: a version and attach, and its root
@@ -1828,7 +1843,10 @@ pub const Client = struct {
var sock_buf: [sun_path_len]u8 = undefined;
const sock = try resolve(&sock_buf, dial);
var remote: RemoteError = .{};
- const result = try fetchBytes(gpa, sock, names[0..n], &remote, bytes, path, limits.max_file_bytes);
+ const result = fetchBytes(gpa, sock, names[0..n], &remote, bytes, path, limits.max_file_bytes) catch |err| {
+ if (err == error.Remote) said = remote;
+ return err;
+ };
gpa.free(result);
}