diff options
| -rw-r--r-- | build.zig | 55 | ||||
| -rw-r--r-- | build/snap.zig | 3 | ||||
| -rw-r--r-- | docs/next-drag.md | 2 | ||||
| -rw-r--r-- | docs/typ/building.typ | 22 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 8 | ||||
| -rw-r--r-- | features.txt | 3 | ||||
| -rw-r--r-- | next-steps.txt | 2 | ||||
| -rw-r--r-- | src/9p_io.zig | 415 | ||||
| -rw-r--r-- | src/9p_quic.zig | 6 | ||||
| -rw-r--r-- | src/CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/fs.zig | 1 | ||||
| -rw-r--r-- | src/ninep/screen.zig | 18 | ||||
| -rw-r--r-- | test/fs_namespace.zig | 1 | ||||
| -rw-r--r-- | test/perf-baseline-gui-debug.json | 2 | ||||
| -rw-r--r-- | test/perf-baseline-tty-debug.json | 2 | ||||
| -rw-r--r-- | test/perf-baseline-tty-fast.json | 2 | ||||
| -rw-r--r-- | test/process.zig | 8 | ||||
| -rw-r--r-- | test/process/flags.zig | 4 | ||||
| -rw-r--r-- | test/process/mounts.zig | 102 |
19 files changed, 68 insertions, 592 deletions
@@ -40,7 +40,6 @@ const PerfBuild = struct { mupdf: bool, jpx: bool, tracy: bool, - quic: bool, theme_animation: bool, terminal_simd: bool, prebuilt_shaders: bool, @@ -118,10 +117,6 @@ pub fn build(b: *std.Build) void { const is_web = platform == .web; const is_esp32p4 = platform == .esp32p4; const freestanding_core = is_web or is_esp32p4; - const enable_quic = b.option(bool, "quic", "optional 9P-over-QUIC transport using system OpenSSL 3.6+ (default off)") orelse false; - if (enable_quic and freestanding_core) @panic("-Dquic=true needs a native platform"); - const ninep_options = b.addOptions(); - ninep_options.addOption(bool, "quic", enable_quic); const enable_mupdf = b.option(bool, "mupdf", "native PDF rendering with MuPDF (AGPL/commercial; native default on, web/esp32p4 off; -Dmupdf=false disables)") orelse !freestanding_core; const enable_jpx = b.option(bool, "jpx", "JPEG 2000 in PDFs, for scanned documents (default on; -Djpx=false drops openjpeg)") orelse true; // Off on the board too: the sources are ~1.8 MB, more than the whole @@ -295,37 +290,6 @@ pub fn build(b: *std.Build) void { const cloud9 = b.dependency("cloud9", .{ .target = target, .optimize = optimize }).module("cloud9"); for (core_mods) |mod| mod.addImport("cloud9", cloud9); const core_shells = core_shells_buf[0..core_mods_len]; - for (core_mods) |mod| mod.addOptions("9p_options", ninep_options); - const quic_test_step = b.step("quic-test", "test optional QUIC transport (-Dquic=true)"); - if (enable_quic) { - const header = b.addWriteFiles().add("openssl.h", "#include <openssl/ssl.h>\n#include <openssl/quic.h>\n#include <openssl/err.h>\n"); - const translated = b.addTranslateC(.{ .root_source_file = header, .target = target, .optimize = optimize, .link_libc = true }); - const include_dir = std.mem.trim(u8, b.run(&.{ "pkg-config", "--variable=includedir", "openssl" }), " \t\r\n"); - if (include_dir.len == 0) @panic("OpenSSL pkg-config metadata is missing its include directory"); - translated.addSystemIncludePath(.{ .cwd_relative = include_dir }); - const openssl = translated.createModule(); - const library_dir = std.mem.trim(u8, b.run(&.{ "pkg-config", "--variable=libdir", "openssl" }), " \t\r\n"); - if (library_dir.len == 0) @panic("OpenSSL pkg-config metadata is missing its library directory"); - openssl.addLibraryPath(.{ .cwd_relative = library_dir }); - openssl.linkSystemLibrary("ssl", .{}); - openssl.linkSystemLibrary("crypto", .{}); - for (core_mods) |mod| mod.addImport("openssl", openssl); - const quic_module = b.createModule(.{ - .target = target, - .optimize = optimize, - .root_source_file = b.path("src/9p_quic.zig"), - .link_libc = true, - }); - quic_module.addImport("openssl", openssl); - quic_module.addImport("cloud9", cloud9); - const tests = b.addTest(.{ .root_module = quic_module, .filters = test_filters }); - if (test_nonce) |nonce| tests.root_module.addImport("test_rebuild_nonce", nonce); - test_build.dependOn(&tests.step); - const run_tests = b.addRunArtifact(tests); - run_tests.has_side_effects = true; - quic_test_step.dependOn(&run_tests.step); - if (testMatch(b, unit_profile, test_filters, quic_test_step)) |check| check.addArtifactArg(tests); - } else quic_test_step.dependOn(&b.addFail("quic-test needs -Dquic=true and system OpenSSL 3.6+").step); // The conditional dependencies, hoisted so one `wireCore` call at the end // can name them all. The unconditional ones are ordinary consts below. @@ -1232,10 +1196,6 @@ pub fn build(b: *std.Build) void { }) |src| link.addFileArg(b.path(b.fmt("src/macos/Sources/{s}", .{src}))); link.addFileArg(lib_archive); - if (enable_quic) { - const ssl_libdir = std.mem.trim(u8, b.run(&.{ "pkg-config", "--variable=libdir", "openssl" }), " \t\r\n"); - link.addArgs(&.{ "-L", ssl_libdir, "-lssl", "-lcrypto" }); - } link.addArgs(&.{ "-lc++", "-framework", @@ -1322,10 +1282,6 @@ pub fn build(b: *std.Build) void { "test/macos_e2e.swift", }) |source| e2e.addFileArg(b.path(source)); e2e.addFileArg(lib_archive); - if (enable_quic) { - const ssl_libdir = std.mem.trim(u8, b.run(&.{ "pkg-config", "--variable=libdir", "openssl" }), " \t\r\n"); - e2e.addArgs(&.{ "-L", ssl_libdir, "-lssl", "-lcrypto" }); - } e2e.addArgs(&.{ "-lc++", "-framework", "AppKit", "-framework", "CoreText", "-framework", "CoreGraphics", "-framework", "CoreImage", "-framework", "Metal" }); const files = b.addWriteFiles(); const runnable = files.addCopyFile(e2e_bin, "pardes-macos-e2e"); @@ -1586,7 +1542,6 @@ pub fn build(b: *std.Build) void { .mupdf = enable_mupdf, .jpx = enable_mupdf and enable_jpx, .tracy = tracy != null, - .quic = enable_quic, .theme_animation = theme_animation orelse (platform != .esp32p4), .terminal_simd = ghostty_simd, .prebuilt_shaders = platform == .gui and prebuilt_shaders, @@ -1871,13 +1826,9 @@ pub fn build(b: *std.Build) void { ninep_io_module.link_objects.appendSlice(b.allocator, core_module.link_objects.items) catch @panic("OOM"); var ninep_imports = core_module.import_table.iterator(); while (ninep_imports.next()) |entry| ninep_io_module.addImport(entry.key_ptr.*, entry.value_ptr.*); - if (enable_quic) { - ninep_io_module.linkSystemLibrary("ssl", .{}); - ninep_io_module.linkSystemLibrary("crypto", .{}); - } const ninep_io_tests = b.addTest(.{ .root_module = ninep_io_module, - .filters = &.{ "Unix TCP", "one fetch", "expired sessions", "posts itself" }, + .filters = &.{ "Unix and TCP", "one fetch", "expired sessions", "posts itself" }, }); b.step("9p-io-test", "run native 9P transport and client integration tests") .dependOn(&b.addRunArtifact(ninep_io_tests).step); @@ -1891,10 +1842,6 @@ pub fn build(b: *std.Build) void { fs_module.link_objects.appendSlice(b.allocator, core_module.link_objects.items) catch @panic("OOM"); var fs_imports = core_module.import_table.iterator(); while (fs_imports.next()) |entry| fs_module.addImport(entry.key_ptr.*, entry.value_ptr.*); - if (enable_quic) { - fs_module.linkSystemLibrary("ssl", .{}); - fs_module.linkSystemLibrary("crypto", .{}); - } const fs_tests = b.addTest(.{ .root_module = fs_module, .filters = test_filters }); b.step("fs-unit-test", "run filesystem unit tests").dependOn(&b.addRunArtifact(fs_tests).step); diff --git a/build/snap.zig b/build/snap.zig index d29eac42..e82bf1ef 100644 --- a/build/snap.zig +++ b/build/snap.zig @@ -19,15 +19,12 @@ pub fn addTty(b: *std.Build, opts: struct { }), }); if (opts.ghostty_vt) |vt| snap.root_module.addImport("ghostty-vt", vt); - const ninep_options = b.addOptions(); - ninep_options.addOption(bool, "quic", false); const ninep_client = b.createModule(.{ .target = opts.target, .optimize = opts.optimize, .root_source_file = b.path("src/9p_io.zig"), .link_libc = true, }); - ninep_client.addOptions("9p_options", ninep_options); ninep_client.addImport("cloud9", opts.cloud9); snap.root_module.addImport("9p_io", ninep_client); snap.root_module.addImport("cloud9", opts.cloud9); diff --git a/docs/next-drag.md b/docs/next-drag.md index d217bf94..5871f785 100644 --- a/docs/next-drag.md +++ b/docs/next-drag.md @@ -145,7 +145,7 @@ the author was using the desktop and the field panned under my pointer. every window show the guide where its pointer is; worth one more step. 8. **Path, not bytes.** `adopt` names a file on this machine; a registry session is local by definition, so it is enough. A mounted remote - session (tcp, quic) would need the zon in the write. + session (tcp) would need the zon in the write. 9. **Asking every window on each drop-out.** Reading the user's other sessions' `status` is harmless (read-only), but an old pardes answers none and a hung one costs its 2 s budget on the worker. Position: fine. diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 99a83589..78cdba7e 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -12,8 +12,7 @@ pieces fit. To install it, see #doc("setup", section: "install"). Zig *0.17.0* (`build.zig.zon` pins `minimum_zig_version`). Dependencies are fetched and pinned by the manifest; the terminal build needs no system package. The SDL shell builds SDL3 and FreeType from source. PDF support -builds MuPDF and is on by default (`-Dmupdf=false` drops it). 9P over QUIC -(`-Dquic=true`) uses system OpenSSL 3.6+ and pkg-config. +builds MuPDF and is on by default (`-Dmupdf=false` drops it). #pairs( [`zig build`], [the terminal shell and the SDL window together, *installed into `~/.local/bin`* (`pardes` and `pardes-gui`)], @@ -47,7 +46,6 @@ there; its namespace is in `src/esp32p4_gpio.zig`. #pairs( [`-Dplatform`], [`tui`, `gui`, `web`, `macos`, `esp32p4`; absent: the tui and SDL shells together, installed into `~/.local`], [`-Dstatic`], [bool, `false`], - [`-Dquic`], [bool, `false`: 9P over QUIC with system OpenSSL 3.6+], [`-Dmupdf`], [bool; on natively, off for web and esp32p4], [`-Djpx`], [bool, `true`: JPEG 2000, and with it scanned PDFs], [`-Dtree-sitter`], [`disabled`, `zig`, `minimal`, `full`; `full` natively, `zig` for web, `disabled` for esp32p4], @@ -87,7 +85,6 @@ zig build gui-golden the hidden window's scenes against this machine's gol zig build monkey-session random in-process 9P requests checking the documented rules zig build 9p-test freestanding protocol tests zig build 9p-io-test native 9P transports and client -zig build quic-test -Dquic=true optional QUIC transport tests zig build snap scripted input traces against frozen golden grids zig build monkey random snapshot scripts hunting panics (not a gate) zig build hxdiff differential suite against helix's own behaviour @@ -254,13 +251,13 @@ registry on its command line. `python3 -B test/daemon.py --upgrade <old> = 9P The wire format, the client and server connections, the file-server engine -and the Unix, TCP and QUIC transports are the `cloud9` package +and the Unix and TCP transports are the `cloud9` package (`git.sr.ht/~gbrls/cloud9`), pinned in `build.zig.zon` and fetched into `zig-pkg/`. Re-pin with `zig fetch --save=cloud9 git+https://git.sr.ht/~gbrls/cloud9#<commit>`, or use `.cloud9 = .{ .path = "../cloud9" }` while editing both. cloud9's own -`zig build test`, `transport-test`, `quic-test -Dquic=true`, `fuzz` and -`differential` cover the shared code. +`zig build test`, `transport-test`, `fuzz` and `differential` cover the +shared code. - The engine (`fs.Server`) owns fids, permissions, directory reads, flushes and what a hangup releases; it allocates nothing and makes no OS @@ -274,9 +271,7 @@ use `.cloud9 = .{ .path = "../cloud9" }` while editing both. cloud9's own attach, stat, create or rename cannot. Every Rread is clamped to the count and the msize; Tflush answers the original request first. - Unix and TCP listeners run on cloud9's `serve.Runner`: an accept task per - listener, a reader and a writer task per connection, 16 connections. QUIC - (`src/9p_quic.zig`) still runs on the editor's poll loop in - `src/9p_io.zig`. + listener, a reader and a writer task per connection, 16 connections. - A body write takes only whole UTF-8 sequences and answers a short count for the rest. Consecutive writes from one open at the end of the text are held and applied as one edit, flushed by any other request, the open's @@ -296,15 +291,12 @@ its newline, is dropped. == Listeners <listeners> -`--9p-tcp='tcp!127.0.0.1!5640'` adds TCP; `--9p-quic='quic!127.0.0.1!5641'` -adds QUIC (built with `-Dquic=true`; ALPN `pardes-9p`, an ephemeral TLS -identity, no peer verification). Addresses are numeric IPv4 or IPv6; port +`--9p-tcp='tcp!127.0.0.1!5640'` adds TCP. Addresses are numeric IPv4 or IPv6; port 0 picks one; #file("/listeners") reads them back. Every connection has full session access, #file("/os") included, and TCP is unencrypted: use loopback. Unix and TCP share 16 connection slots; a 17th client's Tversion gets `too many connections` (and the log -`err - 9p: too many connections (N turned away)`). QUIC has 16 of its own. -plan9port and v9fs need a userspace bridge for QUIC. +`err - 9p: too many connections (N turned away)`). `$XDG_RUNTIME_DIR/9p` is the machine's `/srv`: servers post themselves there by name, and `9ns --mntgen` mounts the whole registry. A pardes whose diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 663bc0af..e0d230d7 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -335,8 +335,8 @@ Explicit paths skip that search: ) `--mount=peer=work` or #word("Mount") `peer <dial>` mounts a dial: `unix!/path`, -`/path`, `tcp!<numeric-ip>!<port>`, a session name, or with `-Dquic` -`quic!…`; a missing socket is ENOENT, `no such socket`; +`/path`, `tcp!<numeric-ip>!<port>` or a session name; a missing socket is +ENOENT, `no such socket`; #word("Unmount") `peer` removes it. #word("Mount") dials at once and fails if nothing answers (`dial failed: no answer`, `timed out`, `hung up`); with no dial it is `wrong #args`, and any other `x!y` `bad dial address`, both @@ -352,7 +352,7 @@ fewer bytes in each round trip). A session may open its own tree through a mount (a #word("Look") of `$m/pane/2/body` from the editor serving `$m`): requests are answered on the connection's -task while the editor waits in its syscall. Through QUIC that still hangs. +task while the editor waits in its syscall. = The root ctl <root-ctl> @@ -1168,7 +1168,7 @@ with Client(sys.argv[1]) as c: # a socket path, or (ip, port) [columns], [16, each at least 10 cells wide], [rows a pane keeps], [its tag and 2], [msize], [65536 (64 KiB) offered], - [connections], [16 Unix and TCP, 16 QUIC], + [connections], [16 Unix and TCP], [open records], [64 a session, every client's together], [held reads a connection], [128], [named mounts], [8], diff --git a/features.txt b/features.txt index 86b2a834..312c51c6 100644 --- a/features.txt +++ b/features.txt @@ -234,8 +234,7 @@ body 283us -> 64us, because a read no longer waits for the editor to wake; a tru -> 543us; pane/new + rmdir 1535us -> 1295us; exec Save 718us -> 583us. A change still costs one editor frame, since the editor draws it before it rests again. -Left as they are: QUIC still runs on the editor's thread (cloud9's QUIC adapter is not std.Io based), so a QUIC client of a session -that Looks at its own QUIC-mounted tree would still wait on the loop; the Tty9p kernel mount lives in the helper's private +Left as they are: the Tty9p kernel mount lives in the helper's private namespace, so a Look on `$PARDES_MOUNT/...` from that shell opens nothing in the editor -- no longer a deadlock, only a namespace the editor is not in; and a message wider than its pane now keeps its tail rather than its head (msg.snap `msgtail`). diff --git a/next-steps.txt b/next-steps.txt index 1f41fc03..dbb65005 100644 --- a/next-steps.txt +++ b/next-steps.txt @@ -1,7 +1,7 @@ This is the original wishlist, not an implementation specification. Current filesystem behavior is documented in docs/typ/reference.typ: default Unix 9P, -optional TCP and QUIC, runtime Mount/Unmount, and OS-first Look resolution. +optional TCP, runtime Mount/Unmount, and OS-first Look resolution. FUSE and the old proof-of-concept examples have been removed. Terminal control and nested Look use 9P; a board build does not imply hardware validation. diff --git a/src/9p_io.zig b/src/9p_io.zig index ab7dd13f..c985845c 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -6,8 +6,9 @@ const cloud9 = @import("cloud9"); const transport = cloud9.transport; const pardes = @import("pardes.zig"); const limits = @import("memory.zig").limits; -pub const quic_enabled = @import("9p_options").quic; -const quic = if (quic_enabled) @import("9p_quic.zig") else struct {}; +// shortcut: main.zig's --9p-quic refusal reads this until the processes +// change takes the flag out; then it goes. +pub const quic_enabled = false; const log = std.log.scoped(.ninep); @@ -62,7 +63,7 @@ extern "c" fn inet_pton(family: c_int, src: [*:0]const u8, dst: *anyopaque) c_in pub fn networkAddress(dial: []const u8, allow_zero_port: bool) error{BadDial}!std.Io.net.IpAddress { if (comptime !supported) return error.BadDial; - const host_start: usize = if (std.mem.startsWith(u8, dial, "tcp!")) 4 else if (std.mem.startsWith(u8, dial, "quic!")) 5 else return error.BadDial; + const host_start: usize = if (std.mem.startsWith(u8, dial, "tcp!")) 4 else return error.BadDial; const split = std.mem.lastIndexOfScalar(u8, dial, '!') orelse return error.BadDial; if (split <= host_start or split + 1 == dial.len) return error.BadDial; const port_text = dial[split + 1 ..]; @@ -131,33 +132,18 @@ fn localIp(address: std.Io.net.IpAddress) bool { return false; } -const Srv = ninep.Server(pardes.ctlfs, ninep.editor); - /// The Unix and TCP listeners run on cloud9's `std.Io` runner: it accepts, /// reads frames, steps each connection's engine and writes replies on its /// own tasks, and every backend request is answered right there, on the /// connection's task, by taking the editor's turn (`pardes.turn`): while the /// editor waits for input, or while a step of it is out in a syscall -- -/// which is what lets the editor read its own tree through a mount. QUIC -/// keeps the poll loop below, on the editor's thread. +/// which is what lets the editor read its own tree through a mount. const Runner = if (supported) cloud9.serve.Runner(pardes.ctlfs, ninep.editor, .{ .msize = msize, .connections = max_conns, .listeners = 2, }) else void; -const quic_slots = if (quic_enabled) max_conns else 0; - -/// A QUIC connection on the poll path. -const Conn = struct { - quic: if (quic_enabled) ?quic.Connection else void = if (quic_enabled) null else {}, - draining: bool = false, - accepted_ms: i64 = 0, - srv: Srv = undefined, - in: [msize]u8 = undefined, - out: [2 * msize]u8 = undefined, -}; - const accept_pause_ms: i64 = 100; pub const Listener = struct { @@ -190,8 +176,6 @@ pub const Listener = struct { /// Connections accepted before this count are being cut by a Restore. cut_before: u64 = 0, tcp_address: ?std.Io.net.IpAddress = null, - quic: if (quic_enabled) ?quic.Listener else void = if (quic_enabled) null else {}, - quic_address: ?std.Io.net.IpAddress = null, paused_ms: i64 = 0, path_buf: [sun_path_len]u8 = undefined, path_len: usize = 0, @@ -202,14 +186,6 @@ pub const Listener = struct { /// (`$XDG_RUNTIME_DIR/9p/pardes/<name>`), zero when it did not. posted_buf: [sun_path_len]u8 = undefined, posted_len: usize = 0, - conns: [quic_slots]Conn = @splat(.{}), - control: [2]c_int = .{ -1, -1 }, - watcher: ?std.Thread = null, - watch_stop: std.atomic.Value(bool) = .init(false), - watch_lock: std.atomic.Mutex = .unlocked, - watch_fds: [2]libc.pollfd = undefined, - watch_len: usize = 0, - watch_timeout: c_int = -1, wake_ctx: ?*anyopaque = null, wake: ?*const fn (?*anyopaque) void = null, @@ -505,160 +481,19 @@ pub const Listener = struct { if (l.wake) |f| f(l.wake_ctx); } - /// Accepts and reads QUIC connections (the runner does its own). - pub fn accept(l: *Listener) void { - if (comptime !quic_enabled) return; - if (l.quic) |*listener| for (0..max_conns + 1) |_| { - var connection = (listener.accept() catch |err| { - log.warn("QUIC accept failed: {s}", .{@errorName(err)}); - return; - }) orelse break; - const c = for (&l.conns, 0..) |*cand, i| { - if (!l.live(@intCast(i)) and !cand.draining) break cand; - } else { - connection.deinit(); - continue; - }; - c.quic = connection; - c.draining = false; - c.accepted_ms = nowMs(); - c.srv = .init(.{ .in = &c.in, .out = &c.out, .root = pardes.ctlfs.root }); - }; - } - pub const greet_deadline_ms: i64 = 5000; - pub fn expire(l: *Listener) void { - if (comptime !quic_enabled) return; - const now = nowMs(); - if (now == 0) return; - for (&l.conns, 0..) |*c, i| { - if (!l.live(@intCast(i)) or c.srv.protocol.msize != 0) continue; - if (now - c.accepted_ms < greet_deadline_ms) continue; - log.debug("QUIC slot {d} never sent Tversion; taking it back", .{i}); - l.drop(@intCast(i)); - } - } - - pub fn nextDue(l: *const Listener) ?i32 { - if (comptime !quic_enabled) return null; - const now = nowMs(); - if (now == 0) return null; - var due: ?i64 = null; - if (l.quic) |*listener| if (listener.nextDue()) |ms| { - const at = now + ms; - due = if (due) |d| @min(d, at) else at; - }; - for (&l.conns, 0..) |*c, i| { - if (!l.live(@intCast(i))) continue; - if (c.quic) |*connection| if (connection.pending()) return 0; - if (c.srv.protocol.msize != 0) continue; - const at = c.accepted_ms + greet_deadline_ms; - due = if (due) |d| @min(d, at) else at; - } - const at = due orelse return null; - return @intCast(@max(0, at - now)); - } - const nowMs = transport.nowMs; - pub fn fill(l: *Listener, i: u8) void { - if (comptime !quic_enabled) return; - const c = &l.conns[i]; - if (c.srv.protocol.dead) return l.drop(i); - const room = c.srv.protocol.in.len - c.srv.protocol.in_len; - if (room == 0) return; - var buf: [msize]u8 = undefined; - const got = (c.quic.?.read(buf[0..@min(room, buf.len)]) catch return l.drop(i)) orelse return; - if (got == 0) return l.drop(i); - const n = c.srv.push(buf[0..@intCast(got)]); - if (c.srv.protocol.dead) return l.drop(i); - std.debug.assert(n == @as(usize, @intCast(got))); - } - - pub fn flush(l: *Listener, i: u8) void { - if (comptime !quic_enabled) return; - const c = &l.conns[i]; - if (!l.live(i)) return; - while (true) { - const bytes = c.srv.output(); - if (bytes.len == 0) return; - const n = c.quic.?.write(bytes) catch return l.drop(i); - if (n == 0) return; - c.srv.wrote(@intCast(n)); - } - } - - pub fn live(l: *const Listener, i: u8) bool { - if (comptime !quic_enabled) return false; - return l.conns[i].quic != null; - } - - pub fn drop(l: *Listener, i: u8) void { - if (comptime !quic_enabled) return; - const c = &l.conns[i]; - if (c.quic) |*connection| { - connection.deinit(); - c.quic = null; - } - if (c.draining or c.accepted_ms == 0) return; - c.srv.hangup(); - c.draining = true; - } - - /// What one QUIC poll pass did: `pending` says there is more to do at - /// once. + /// What a frontend's poll of the listener did; the runner's own tasks + /// serve every connection, so there is never more to do at once. pub const Polled = struct { count: usize = 0, pending: bool = false }; - /// Answers one QUIC request, on the editor's thread. - fn step(l: *Listener, srv: *Srv, req: pardes.ctlfs.Req) void { - l.core.fs.write_room = if (srv.protocol.msize > 24) srv.protocol.msize - 24 else 0; - const reply = l.core.serveFs(req); - srv.reply(&reply, l.core.fsPayload(reply)); - if (req.op == .release) l.collectOs(); - } - - /// QUIC's events, accepts, reads, requests and replies, on the editor's - /// thread after each of its steps; `pending` says there is more to do - /// right away. Unix and TCP need none of this. + /// Between the editor's steps, which is when the host paths may be + /// swept: the editor's own directory listings leave nodes in it too. pub fn tick(l: *Listener) Polled { - var result: Polled = .{}; - // Between the editor's steps, which is when the table may be swept: - // the editor's own directory listings leave nodes in it too. l.collectOs(); - if (comptime quic_enabled) { - if (l.quic) |*listener| listener.events() catch |err| { - log.warn("QUIC listener stopped: {s}", .{@errorName(err)}); - for (&l.conns, 0..) |*conn, i| if (conn.quic != null) l.drop(@intCast(i)); - listener.deinit(); - l.quic = null; - l.quic_address = null; - }; - l.accept(); - for (0..quic_slots) |i| if (l.live(@intCast(i))) l.fill(@intCast(i)); - l.expire(); - for (&l.conns, 0..) |*conn, i| { - if (!l.live(@intCast(i)) and !conn.draining) continue; - var count: usize = 0; - while (conn.srv.retry()) |req| { - l.step(&conn.srv, req); - count += 1; - } - while (count < 64) { - const req = conn.srv.next() orelse break; - l.step(&conn.srv, req); - count += 1; - } - result.count += count; - result.pending = result.pending or count >= 64; - if (conn.draining) { - if (count == 0) conn.draining = false else result.pending = true; - } else l.flush(@intCast(i)); - if (conn.quic) |*connection| result.pending = result.pending or connection.pending(); - } - l.arm(); - } - return result; + return .{}; } /// Hangs every connection up, so that `replacement` starts with no @@ -675,12 +510,9 @@ pub const Listener = struct { l.core.fs.news = true; answerHeld(l); l.core.fs.hanging_up = false; - for (0..quic_slots) |i| l.drop(@intCast(i)); - if (comptime quic_enabled) while (l.tick().pending) {}; l.core = replacement; replacement.fs.socket_path = l.path(); replacement.fs.tcp_address = l.tcp_address; - replacement.fs.quic_address = l.quic_address; if (comptime supported) { // The Restore's writer answers as it wakes (`onServe`), and its // answer gets 200 ms to leave before the cut; every other request @@ -716,8 +548,6 @@ pub const Listener = struct { l.cut_before = 0; } l.collectOs(); - for (&l.conns) |*conn| conn.accepted_ms = 0; - l.arm(); } /// Forgets the host paths no connection names any more. With the turn, @@ -753,70 +583,13 @@ pub const Listener = struct { if (conn.engine.references(node)) return true; } } - for (&l.conns, 0..) |*conn, j| { - if (!l.live(@intCast(j)) and !conn.draining) continue; - if (conn.srv.references(node)) return true; - } return false; } - /// Where the runner's tasks report that a request changed the core, - /// and for QUIC a thread that watches its socket and calls `wake` when - /// `tick` has something to read. + /// Where the runner's tasks report that a request changed the core. pub fn watch(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) !void { l.wake_ctx = ctx; l.wake = wake; - if (comptime !quic_enabled) return; - if (l.quic == null or l.watcher != null) return; - if (libc.pipe(&l.control) != 0) return error.PipeFailed; - errdefer { - _ = libc.close(l.control[0]); - _ = libc.close(l.control[1]); - l.control = .{ -1, -1 }; - } - for (l.control) |fd| { - setCloexec(fd); - _ = setNonblock(fd); - } - l.arm(); - l.watcher = try std.Thread.spawn(.{}, watchQuic, .{l}); - } - - fn arm(l: *Listener) void { - if (comptime !quic_enabled) return; - if (l.control[1] < 0) return; - while (!l.watch_lock.tryLock()) std.atomic.spinLoopHint(); - l.watch_fds[0] = .{ .fd = l.control[0], .events = @intCast(libc.POLL.IN), .revents = 0 }; - l.watch_len = 1; - if (l.quic) |*listener| { - l.watch_fds[l.watch_len] = listener.poll(); - l.watch_len += 1; - } - l.watch_timeout = l.nextDue() orelse -1; - l.watch_lock.unlock(); - _ = libc.write(l.control[1], "w", 1); - } - - fn watchQuic(l: *Listener) void { - var notified = false; - while (!l.watch_stop.load(.acquire)) { - var fds: [2]libc.pollfd = undefined; - while (!l.watch_lock.tryLock()) std.atomic.spinLoopHint(); - const len = if (notified) 1 else l.watch_len; - @memcpy(fds[0..len], l.watch_fds[0..len]); - const timeout = if (notified) -1 else l.watch_timeout; - l.watch_lock.unlock(); - const ready = libc.poll(&fds, @intCast(len), timeout); - if (ready < 0) continue; - if (fds[0].revents != 0) { - var buf: [64]u8 = undefined; - while (libc.read(l.control[0], &buf, buf.len) > 0) {} - notified = false; - continue; - } - if (!l.watch_stop.load(.acquire)) l.wake.?(l.wake_ctx); - notified = true; - } } /// Advertises this editor in the posted-9P registry so a @@ -924,16 +697,6 @@ pub const Listener = struct { pub fn deinit(l: *Listener, gpa: std.mem.Allocator) void { l.stopping.store(true, .release); l.unpostFromRegistry(); - if (l.watcher) |thread| { - l.watch_stop.store(true, .release); - _ = libc.write(l.control[1], "q", 1); - thread.join(); - for (l.control) |fd| _ = libc.close(fd); - } - for (0..quic_slots) |i| l.drop(@intCast(i)); - if (comptime quic_enabled) { - if (l.quic) |*listener| listener.deinit(); - } if (comptime supported) { // A connection task may be waiting for the turn; it answers // nothing more once stopping, but the wait itself must end. @@ -1159,7 +922,7 @@ pub fn socketPath(buf: *[sun_path_len]u8, dir: []const u8, name: []const u8) ?[: /// Serves `core`. From here on the calling thread has the editor's turn /// (`pardes.turn`) and must give it up while it waits. -pub fn listen(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8, quic_dial: ?[]const u8) ?*Listener { +pub fn listen(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8) ?*Listener { if (comptime !supported) return null; var dir_buf: [sun_path_len:0]u8 = undefined; const dir = socketDir(&dir_buf) orelse { @@ -1271,34 +1034,9 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes, named: [ l.tcp_address = canonicalIp(bound); log.info("serving 9P2000 over TCP on {f}", .{l.tcp_address.?}); } - if (quic_dial) |dial| { - if (comptime quic_enabled) { - if (!std.mem.startsWith(u8, dial, "quic!")) { - l.deinit(gpa); - return null; - } - const address = networkAddress(dial, true) catch { - log.warn("invalid QUIC address {s}", .{dial}); - l.deinit(gpa); - return null; - }; - l.quic = quic.Listener.init(address) catch |err| { - log.warn("cannot listen on {s}: {s}", .{ dial, @errorName(err) }); - l.deinit(gpa); - return null; - }; - l.quic_address = l.quic.?.address; - log.info("serving 9P2000 over QUIC on {f}", .{l.quic_address.?}); - } else { - log.warn("QUIC is unavailable in this build", .{}); - l.deinit(gpa); - return null; - } - } log.info("serving 9P2000 on {s}", .{p}); core.fs.socket_path = l.path(); core.fs.tcp_address = l.tcp_address; - core.fs.quic_address = l.quic_address; return l; } @@ -1656,10 +1394,6 @@ test "one connection's buffers are sized from the one msize constant" { try testing.expectEqual(@as(usize, msize), @typeInfo(@FieldType(Runner.Conn, "in")).array.len); try testing.expectEqual(@as(usize, 2 * msize), @typeInfo(@FieldType(Runner.Conn, "out")).array.len); try testing.expectEqual(@as(usize, max_conns), Runner.max_connections); - if (quic_enabled) { - const c: Conn = .{}; - try testing.expectEqual(@as(usize, msize), c.in.len); - } } test "TCP addresses are numeric and normalize mapped IPv4" { @@ -1681,9 +1415,7 @@ test "TCP addresses are numeric and normalize mapped IPv4" { try testing.expectError(error.BadDial, Client.validateDial("unix!/tmp/a\x00b")); try testing.expectError(error.BadDial, Client.validateDial("tcp!localhost!5640")); try testing.expectError(error.BadDial, Client.validateDial("/tmp/a\x00b")); - if (quic_enabled) { - try Client.validateDial("quic!127.0.0.1!5640"); - } else try testing.expectError(error.QuicUnavailable, Client.validateDial("quic!127.0.0.1!5640")); + try testing.expectError(error.BadDial, Client.validateDial("quic!127.0.0.1!5640")); } extern "c" fn mkdtemp(template: [*:0]u8) ?[*:0]u8; @@ -1712,7 +1444,7 @@ test "a socket path too long for sun_path is no listener, and leaves the editor' _ = @import("host_io.zig").testUnsetenv("XDG_RUNTIME_DIR"); }; const long = &@as([120]u8, @splat('n')); - try testing.expect(listen(testing.io, testing.allocator, p, long, "", null, null) == null); + try testing.expect(listen(testing.io, testing.allocator, p, long, "", null) == null); try testing.expect(pardes.turn.answer_held == null); try testing.expect(pardes.turn.wake_parked == null); try testing.expect(pardes.turn.io == null); @@ -1755,7 +1487,7 @@ test "a listening editor posts itself into the 9P registry and unposts on stop" { const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); - const l = listen(testing.io, gpa, p, "unit", "", null, null) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, p, "unit", "", null) orelse return error.ListenFailed; defer l.deinit(gpa); // The socket stays exactly where pardes has always bound it: // adopting the registry moves nothing, it only advertises. @@ -1789,7 +1521,7 @@ test "a listening editor posts itself into the 9P registry and unposts on stop" try testing.expectEqual(Probe.none, lockState(sock)); } -test "Unix TCP and QUIC share one listener through reads writes reconnects and reset" { +test "Unix and TCP share one listener through reads writes reconnects and reset" { if (comptime !supported) return error.SkipZigTest; const gpa = testing.allocator; var directory: [64:0]u8 = undefined; @@ -1850,28 +1582,24 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r } }; - const protocols: []const []const u8 = if (quic_enabled) &.{ "tcp", "quic" } else &.{"tcp"}; - for (protocols) |protocol| for ([_][]const u8{ "127.0.0.1", "::1" }) |host| { + for ([_][]const u8{ "127.0.0.1", "::1" }) |host| { const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); const pane = try p.setTestFile("initial\n"); while (p.nextEffect()) |_| {} var bind_buf: [64]u8 = undefined; - const bind = try std.fmt.bufPrint(&bind_buf, "{s}!{s}!0", .{ protocol, host }); - const tcp = std.mem.eql(u8, protocol, "tcp"); - const l = listen(testing.io, gpa, p, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; + const bind = try std.fmt.bufPrint(&bind_buf, "tcp!{s}!0", .{host}); + const l = listen(testing.io, gpa, p, "roundtrip", "", bind) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); } try testing.expect(l.path().len != 0); - try testing.expectEqual(tcp, l.tcp_address != null); try testing.expectEqual(@as(usize, max_conns), l.runner.conns.len); - try testing.expect(l.watcher == null); - const port = (if (tcp) l.tcp_address else l.quic_address).?.getPort(); + const port = l.tcp_address.?.getPort(); try testing.expect(port != 0); var dial_buf: [64]u8 = undefined; - const network_dial = try std.fmt.bufPrint(&dial_buf, "{s}!{s}!{d}", .{ protocol, host, port }); + const network_dial = try std.fmt.bufPrint(&dial_buf, "tcp!{s}!{d}", .{ host, port }); var body_buf: [64]u8 = undefined; const body = try std.fmt.bufPrint(&body_buf, "/pane/{d}/body", .{pane.serial}); for ([_][]const u8{ network_dial, l.path(), network_dial }, 0..) |dial, attempt| { @@ -1882,14 +1610,7 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r // answered on the runner's tasks, not by this thread. const deadline = Client.nowMs() + 3 * Client.budget_ms; pardes.turn.rest(); - while (!worker.done.load(.acquire) and Client.nowMs() < deadline) { - if (quic_enabled) { - pardes.turn.wake(); - _ = l.tick(); - pardes.turn.rest(); - } - Client.nap(1); - } + while (!worker.done.load(.acquire) and Client.nowMs() < deadline) Client.nap(1); // The client has hung up, but its connection's task may not have // seen that yet. The releases it then owes are refused once // `reset` starts cutting (they name the old editor's opens), and @@ -1904,10 +1625,9 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r try testing.expectEqual(@as(usize, 0), l.runner.count()); 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.opens) |o| try testing.expect(o.node == 0); } - }; + } } test "a change waits while the editor is out mid-step, a read does not, and the change lands when the editor rests" { @@ -1932,7 +1652,7 @@ test "a change waits while the editor is out mid-step, a read does not, and the const pane = try p.setTestFile("before\n"); while (p.nextEffect()) |_| {} // This thread is the editor's: it has the turn from here on. - const l = listen(testing.io, gpa, p, "park", "", null, null) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, p, "park", "", null) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); @@ -2008,7 +1728,7 @@ test "a mount's connection is kept between operations, and one the peer hung up defer p.deinit(); const pane = try p.setTestFile("before\n"); while (p.nextEffect()) |_| {} - const l = listen(testing.io, gpa, p, "kept", "", null, null) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, p, "kept", "", null) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); @@ -2096,7 +1816,7 @@ test "a held read is answered when the log has news, and a flushed one spends no _ = try p.setTestFile("held\n"); p.update(.tick); // the pane is logged, before the log is opened while (p.nextEffect()) |_| {} - const l = listen(testing.io, gpa, p, "held", "", null, null) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, p, "held", "", null) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); @@ -2232,7 +1952,7 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene var name: [16]u8 = undefined; // unreachable: a u32 is at most 10 digits const fallback = std.fmt.bufPrint(&name, "{d}", .{@as(u32, @intCast(libc.getpid()))}) catch unreachable; - return listen(io, gpa, core, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { + return listen(io, gpa, core, core.opts.ninep_name, fallback, core.opts.ninep_tcp) orelse { core.reportError(0, "9p listener", error.ListenFailed); return null; }; @@ -2386,7 +2106,7 @@ pub const Client = struct { const uname = "pardes"; - const Dial = union(enum) { unix: [:0]const u8, tcp: std.Io.net.IpAddress, quic: std.Io.net.IpAddress }; + const Dial = union(enum) { unix: [:0]const u8, tcp: std.Io.net.IpAddress }; pub const Error = error{ PathTooDeep, @@ -2399,7 +2119,6 @@ pub const Client = struct { IsDirectory, NotFound, FileTooLarge, - QuicUnavailable, }; pub fn read(gpa: std.mem.Allocator, dial: []const u8, path: []const u8, display_path: []const u8) ![]u8 { @@ -2500,13 +2219,9 @@ pub const Client = struct { return n; } - fn resolve(buf: *[sun_path_len]u8, dial: []const u8) error{ BadDial, QuicUnavailable }!Dial { + fn resolve(buf: *[sun_path_len]u8, dial: []const u8) error{BadDial}!Dial { if (dial.len == 0) return error.BadDial; if (std.mem.startsWith(u8, dial, "tcp!")) return .{ .tcp = try networkAddress(dial, false) }; - if (std.mem.startsWith(u8, dial, "quic!")) { - if (comptime !quic_enabled) return error.QuicUnavailable; - return .{ .quic = try networkAddress(dial, false) }; - } const explicit_unix = std.mem.startsWith(u8, dial, "unix!"); // A network this does not dial (`nowhere!x`) is a malformed address, // not a session named so. @@ -2525,14 +2240,13 @@ pub const Client = struct { return .{ .unix = socketPath(buf, dir, dial) orelse return error.BadDial }; } - pub fn validateDial(dial: []const u8) error{ BadDial, QuicUnavailable }!void { + pub fn validateDial(dial: []const u8) error{BadDial}!void { var buf: [sun_path_len]u8 = undefined; _ = try resolve(&buf, dial); } const Session = struct { fd: c_int, - quic: if (quic_enabled) ?quic.Connection else void = if (quic_enabled) null else {}, deadline: i64, display_path: []const u8, cl: ninep.Client = undefined, @@ -2553,46 +2267,17 @@ pub const Client = struct { dial_len: usize = 0, fn wait(s: *Session, events: i16) Error!void { - while (true) { - const left = s.deadline - nowMs(); - if (left <= 0) return Error.Timeout; - if (comptime quic_enabled) { - if (s.quic) |*connection| { - var fds = [1]libc.pollfd{connection.poll().?}; - const timeout = @min(left, connection.nextDue() orelse budget_ms); - const ready = libc.poll(&fds, 1, @intCast(timeout)); - if (ready < 0) { - if (libc.errno(ready) == .INTR) continue; - return Error.Hangup; - } - if (nowMs() >= s.deadline) return Error.Timeout; - if (fds[0].revents & @as(i16, @intCast(libc.POLL.NVAL)) != 0) return Error.Hangup; - connection.events() catch return Error.Hangup; - return; - } - } - return transport.wait(s.fd, events, s.deadline) catch |err| switch (err) { - error.Timeout => Error.Timeout, - else => Error.Hangup, - }; - } + if (s.deadline - nowMs() <= 0) return Error.Timeout; + return transport.wait(s.fd, events, s.deadline) catch |err| switch (err) { + error.Timeout => Error.Timeout, + else => Error.Hangup, + }; } fn flush(s: *Session) Error!void { while (s.cl.output().len != 0) { if (nowMs() >= s.deadline) return Error.Timeout; const bytes = s.cl.output(); - if (comptime quic_enabled) { - if (s.quic) |*connection| { - const sent = connection.write(bytes) catch return Error.Hangup; - if (sent == 0) { - try s.wait(poll_out); - continue; - } - s.cl.wrote(sent); - continue; - } - } try s.wait(poll_out); const sent = (transport.write(s.fd, bytes) catch return Error.Hangup) orelse continue; s.cl.wrote(@intCast(sent)); @@ -2613,18 +2298,6 @@ pub const Client = struct { if (s.cl.dead) return Error.Botch; const room = s.cl.in.len - s.cl.in_len; if (room == 0) return Error.Botch; - if (comptime quic_enabled) { - if (s.quic) |*connection| { - const got = (connection.read(s.stage[0..@min(room, s.stage.len)]) catch return Error.Hangup) orelse { - try s.wait(poll_in); - continue; - }; - if (got == 0) return Error.Hangup; - const n = s.cl.push(s.stage[0..got]); - std.debug.assert(n == got); - continue; - } - } try s.wait(poll_in); const got = (transport.read(s.fd, s.stage[0..@min(room, s.stage.len)]) catch return Error.Hangup) orelse continue; if (got == 0) return Error.Hangup; @@ -3085,12 +2758,7 @@ pub const Client = struct { const s = try std.heap.page_allocator.create(Session); s.* = .{ .fd = -1, .deadline = deadline, .display_path = display_path }; errdefer endSession(s, false); - if (sock == .quic) { - if (comptime quic_enabled) { - s.quic = quic.Connection.dial(sock.quic) catch return Error.Dial; - s.fd = s.quic.?.fd; - } else return Error.QuicUnavailable; - } else s.fd = try connect(sock, deadline); + s.fd = try connect(sock, deadline); s.cl = .init(.{ .in = &s.in, .out = &s.out }); if (dial.len <= s.dial_buf.len) { @memcpy(s.dial_buf[0..dial.len], dial); @@ -3100,10 +2768,8 @@ pub const Client = struct { } fn endSession(s: *Session, keep: bool) void { - if (keep and s.attached and s.dial_len != 0 and !(quic_enabled and s.quic != null) and kept.put(s)) return; - if (quic_enabled and s.quic != null) { - s.quic.?.deinit(); - } else if (s.fd >= 0) _ = libc.close(s.fd); + if (keep and s.attached and s.dial_len != 0 and kept.put(s)) return; + if (s.fd >= 0) _ = libc.close(s.fd); std.heap.page_allocator.destroy(s); } @@ -3250,7 +2916,6 @@ pub const Client = struct { const address: transport.Address = switch (sock) { .unix => |path| .{ .unix = path }, .tcp => |ip| .{ .tcp = ip }, - .quic => return Error.QuicUnavailable, }; return transport.connectFd(address, deadline) catch return Error.Dial; } @@ -3315,10 +2980,8 @@ pub const Client = struct { } test "one fetch has three msize buffers and bounded transport metadata" { - const transport_bytes = if (quic_enabled) @sizeOf(?quic.Connection) else 0; try testing.expectEqual(@as(usize, msize), @as(usize, (Session{ .fd = -1, .deadline = 0, .display_path = "" }).in.len)); - try testing.expect(transport_bytes <= 64); - try testing.expect(@sizeOf(Session) <= 3 * msize + @sizeOf(ninep.Client) + 128 + @sizeOf(@FieldType(Session, "dial_buf")) + transport_bytes); + try testing.expect(@sizeOf(Session) <= 3 * msize + @sizeOf(ninep.Client) + 128 + @sizeOf(@FieldType(Session, "dial_buf"))); try testing.expect(@sizeOf(ninep.Client) <= 512); } diff --git a/src/9p_quic.zig b/src/9p_quic.zig deleted file mode 100644 index 12912085..00000000 --- a/src/9p_quic.zig +++ /dev/null @@ -1,6 +0,0 @@ -//! Pardes selects its existing ALPN; transport implementation lives in cloud9. -const transport = @import("cloud9").Quic(@import("openssl"), "pardes-9p"); -pub const Listener = transport.Listener; -pub const Connection = transport.Connection; -pub const Error = transport.Error; -pub const alpn = transport.alpn; diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 25d167f4..29675db9 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- 9P over QUIC is gone: the `-Dquic` build with its OpenSSL, `quic!` + dials for `--9p-quic` and Mount, the poll loop that served them on the + editor's thread, and their tests. Unix and TCP serve and mount sessions + as before. - `Placement`, `BootShell`, `LookWord`, `DirLook` and `DiffLook` are gone, with what each kept of pardes before it took acme's ways: its own placement (`Placement pardes`, `SPC c p`), a dragged document closing @@ -1324,7 +1324,6 @@ pub const EditHold = struct { pub const Namespace = struct { socket_path: []const u8 = "", tcp_address: ?std.Io.net.IpAddress = null, - quic_address: ?std.Io.net.IpAddress = null, mounts: std.ArrayList(Mount) = .empty, node_name: [16]u8 = undefined, os_paths: std.ArrayList(OsPath) = .empty, diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig index ba676ded..22129546 100644 --- a/src/ninep/screen.zig +++ b/src/ninep/screen.zig @@ -63,15 +63,10 @@ pub fn listenersText(p: *Pardes, buf: []u8) []const u8 { var text = std.Io.Writer.fixed(buf); if (p.fs.socket_path.len != 0) text.print("unix!{s}\n", .{p.fs.socket_path}) catch return text.buffered(); - for ([_]?std.Io.net.IpAddress{ p.fs.tcp_address, p.fs.quic_address }, [_][]const u8{ "tcp", "quic" }) |maybe, transport| { - const address = maybe orelse continue; - switch (address) { - .ip4 => |ip| text.print("{s}!{d}.{d}.{d}.{d}!{d}\n", .{ transport, ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch - return text.buffered(), - .ip6 => |ip| text.print("{s}!{f}!{d}\n", .{ transport, std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch - return text.buffered(), - } - } + if (p.fs.tcp_address) |address| switch (address) { + .ip4 => |ip| text.print("tcp!{d}.{d}.{d}.{d}!{d}\n", .{ ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch {}, + .ip6 => |ip| text.print("tcp!{f}!{d}\n", .{ std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch {}, + }; return text.buffered(); } @@ -102,9 +97,8 @@ test "listener addresses are readable canonical dials with bounded partial reads const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); p.fs.socket_path = "/tmp/a socket.sock"; - p.fs.tcp_address = .{ .ip4 = .loopback(5640) }; - p.fs.quic_address = .{ .ip6 = .loopback(5641) }; - const expected = "unix!/tmp/a socket.sock\ntcp!127.0.0.1!5640\nquic!::1!5641\n"; + p.fs.tcp_address = .{ .ip6 = .loopback(5641) }; + const expected = "unix!/tmp/a socket.sock\ntcp!::1!5641\n"; for ([_][]const u8{ "/virtual/listeners", "/n/self/listeners" }) |path| { const bytes = try fs.read(p, path); defer gpa.free(bytes); diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index c68a438b..2fda05fd 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -92,7 +92,6 @@ test "transactional restore preserves host capabilities and advances pane identi p.native_images = true; p.fs.socket_path = "/tmp/session.sock"; p.fs.tcp_address = .{ .ip4 = .loopback(5640) }; - p.fs.quic_address = .{ .ip6 = .loopback(5641) }; try pardes.dump.dumpState(p); const restored = try pardes.dump.restore(p, p.dump_out.?, "test"); defer restored.deinit(); diff --git a/test/perf-baseline-gui-debug.json b/test/perf-baseline-gui-debug.json index 4f97a834..78c4f9ce 100644 --- a/test/perf-baseline-gui-debug.json +++ b/test/perf-baseline-gui-debug.json @@ -1 +1 @@ -{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2065,"med_us":2303,"p90_us":2587,"max_us":3268},{"op":"render","fixture":"medium","min_us":90,"med_us":93,"p90_us":96,"max_us":99},{"op":"key-down","fixture":"medium","min_us":99,"med_us":104,"p90_us":114,"max_us":115},{"op":"key-right","fixture":"medium","min_us":100,"med_us":102,"p90_us":104,"max_us":108},{"op":"page-down","fixture":"medium","min_us":98,"med_us":100,"p90_us":114,"max_us":115},{"op":"wheel","fixture":"medium","min_us":95,"med_us":99,"p90_us":105,"max_us":106},{"op":"edit-char","fixture":"medium","min_us":1084,"med_us":1287,"p90_us":1461,"max_us":1655},{"op":"edit-twin","fixture":"medium","min_us":913,"med_us":1303,"p90_us":1531,"max_us":1687},{"op":"body-2m","fixture":"medium","min_us":5120,"med_us":10396,"p90_us":12244,"max_us":13939},{"op":"body-appends","fixture":"medium","min_us":149170,"med_us":235049,"p90_us":263142,"max_us":275060},{"op":"deep-sel","fixture":"medium","min_us":81,"med_us":83,"p90_us":95,"max_us":103}]} +{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2065,"med_us":2303,"p90_us":2587,"max_us":3268},{"op":"render","fixture":"medium","min_us":90,"med_us":93,"p90_us":96,"max_us":99},{"op":"key-down","fixture":"medium","min_us":99,"med_us":104,"p90_us":114,"max_us":115},{"op":"key-right","fixture":"medium","min_us":100,"med_us":102,"p90_us":104,"max_us":108},{"op":"page-down","fixture":"medium","min_us":98,"med_us":100,"p90_us":114,"max_us":115},{"op":"wheel","fixture":"medium","min_us":95,"med_us":99,"p90_us":105,"max_us":106},{"op":"edit-char","fixture":"medium","min_us":1084,"med_us":1287,"p90_us":1461,"max_us":1655},{"op":"edit-twin","fixture":"medium","min_us":913,"med_us":1303,"p90_us":1531,"max_us":1687},{"op":"body-2m","fixture":"medium","min_us":5120,"med_us":10396,"p90_us":12244,"max_us":13939},{"op":"body-appends","fixture":"medium","min_us":149170,"med_us":235049,"p90_us":263142,"max_us":275060},{"op":"deep-sel","fixture":"medium","min_us":81,"med_us":83,"p90_us":95,"max_us":103}]} diff --git a/test/perf-baseline-tty-debug.json b/test/perf-baseline-tty-debug.json index adc1f23c..15e08111 100644 --- a/test/perf-baseline-tty-debug.json +++ b/test/perf-baseline-tty-debug.json @@ -1 +1 @@ -{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2131,"med_us":2550,"p90_us":2652,"max_us":2657},{"op":"render","fixture":"medium","min_us":91,"med_us":95,"p90_us":95,"max_us":98},{"op":"key-down","fixture":"medium","min_us":100,"med_us":101,"p90_us":110,"max_us":114},{"op":"key-right","fixture":"medium","min_us":99,"med_us":103,"p90_us":110,"max_us":116},{"op":"page-down","fixture":"medium","min_us":99,"med_us":102,"p90_us":113,"max_us":114},{"op":"wheel","fixture":"medium","min_us":98,"med_us":100,"p90_us":101,"max_us":115},{"op":"edit-char","fixture":"medium","min_us":1029,"med_us":1242,"p90_us":1379,"max_us":1474},{"op":"edit-twin","fixture":"medium","min_us":1020,"med_us":1348,"p90_us":1453,"max_us":1493},{"op":"body-2m","fixture":"medium","min_us":5544,"med_us":8619,"p90_us":10736,"max_us":12537},{"op":"body-appends","fixture":"medium","min_us":128223,"med_us":186404,"p90_us":230106,"max_us":267921},{"op":"deep-sel","fixture":"medium","min_us":80,"med_us":83,"p90_us":87,"max_us":87}]} +{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2131,"med_us":2550,"p90_us":2652,"max_us":2657},{"op":"render","fixture":"medium","min_us":91,"med_us":95,"p90_us":95,"max_us":98},{"op":"key-down","fixture":"medium","min_us":100,"med_us":101,"p90_us":110,"max_us":114},{"op":"key-right","fixture":"medium","min_us":99,"med_us":103,"p90_us":110,"max_us":116},{"op":"page-down","fixture":"medium","min_us":99,"med_us":102,"p90_us":113,"max_us":114},{"op":"wheel","fixture":"medium","min_us":98,"med_us":100,"p90_us":101,"max_us":115},{"op":"edit-char","fixture":"medium","min_us":1029,"med_us":1242,"p90_us":1379,"max_us":1474},{"op":"edit-twin","fixture":"medium","min_us":1020,"med_us":1348,"p90_us":1453,"max_us":1493},{"op":"body-2m","fixture":"medium","min_us":5544,"med_us":8619,"p90_us":10736,"max_us":12537},{"op":"body-appends","fixture":"medium","min_us":128223,"med_us":186404,"p90_us":230106,"max_us":267921},{"op":"deep-sel","fixture":"medium","min_us":80,"med_us":83,"p90_us":87,"max_us":87}]} diff --git a/test/perf-baseline-tty-fast.json b/test/perf-baseline-tty-fast.json index add1b6af..8932a150 100644 --- a/test/perf-baseline-tty-fast.json +++ b/test/perf-baseline-tty-fast.json @@ -1 +1 @@ -{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"fast","c_optimize":"fast","terminal_optimize":"fast","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2096,"med_us":2329,"p90_us":2589,"max_us":2704},{"op":"render","fixture":"medium","min_us":77,"med_us":80,"p90_us":85,"max_us":86},{"op":"key-down","fixture":"medium","min_us":84,"med_us":87,"p90_us":101,"max_us":116},{"op":"key-right","fixture":"medium","min_us":84,"med_us":87,"p90_us":93,"max_us":111},{"op":"page-down","fixture":"medium","min_us":85,"med_us":86,"p90_us":89,"max_us":102},{"op":"wheel","fixture":"medium","min_us":83,"med_us":87,"p90_us":98,"max_us":107},{"op":"edit-char","fixture":"medium","min_us":886,"med_us":1127,"p90_us":1466,"max_us":1503},{"op":"edit-twin","fixture":"medium","min_us":928,"med_us":1282,"p90_us":1489,"max_us":1586},{"op":"body-2m","fixture":"medium","min_us":5327,"med_us":8382,"p90_us":10779,"max_us":11879},{"op":"body-appends","fixture":"medium","min_us":140582,"med_us":203008,"p90_us":242154,"max_us":252106},{"op":"deep-sel","fixture":"medium","min_us":71,"med_us":74,"p90_us":75,"max_us":77}]} +{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"fast","c_optimize":"fast","terminal_optimize":"fast","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2096,"med_us":2329,"p90_us":2589,"max_us":2704},{"op":"render","fixture":"medium","min_us":77,"med_us":80,"p90_us":85,"max_us":86},{"op":"key-down","fixture":"medium","min_us":84,"med_us":87,"p90_us":101,"max_us":116},{"op":"key-right","fixture":"medium","min_us":84,"med_us":87,"p90_us":93,"max_us":111},{"op":"page-down","fixture":"medium","min_us":85,"med_us":86,"p90_us":89,"max_us":102},{"op":"wheel","fixture":"medium","min_us":83,"med_us":87,"p90_us":98,"max_us":107},{"op":"edit-char","fixture":"medium","min_us":886,"med_us":1127,"p90_us":1466,"max_us":1503},{"op":"edit-twin","fixture":"medium","min_us":928,"med_us":1282,"p90_us":1489,"max_us":1586},{"op":"body-2m","fixture":"medium","min_us":5327,"med_us":8382,"p90_us":10779,"max_us":11879},{"op":"body-appends","fixture":"medium","min_us":140582,"med_us":203008,"p90_us":242154,"max_us":252106},{"op":"deep-sel","fixture":"medium","min_us":71,"med_us":74,"p90_us":75,"max_us":77}]} diff --git a/test/process.zig b/test/process.zig index 57f12e10..a3679dfd 100644 --- a/test/process.zig +++ b/test/process.zig @@ -1088,14 +1088,6 @@ pub fn check(ok: bool, comptime what: []const u8, args: anytype) !void { return error.TestUnexpectedResult; } -/// Whether `exe` was built with QUIC (-Dquic=true): refused for that, or -/// for --attach's own reason, which comes after. -pub fn quicIncluded(gpa: std.mem.Allocator, exe: [:0]const u8) !bool { - const r = try run(gpa, &.{ exe, "--attach=work", "--9p-quic=quic!127.0.0.1!0" }, .{}); - defer gpa.free(r.said); - return !has(r.said, "QUIC is not included"); -} - fn removeDir(path: []const u8) void { var cmd: [4200]u8 = undefined; if (std.fmt.bufPrintSentinel(&cmd, "rm -rf -- '{s}'", .{path}, 0)) |c| { diff --git a/test/process/flags.zig b/test/process/flags.zig index e8f30504..7a1118f0 100644 --- a/test/process/flags.zig +++ b/test/process/flags.zig @@ -221,9 +221,7 @@ fn forwarding(gpa: std.mem.Allocator, exe: [:0]const u8) !void { .{ "shells", &.{ "-n", "3" }, null }, .{ "toggle", &.{ "--tty", "--tty-toggle=q" }, null }, .{ "toggle-arg", &.{ "--tty", "--tty-toggle", "q" }, null }, - .{ "quic", &.{ "--tty", "--9p-quic=quic!127.0.0.1!0" }, null }, }) |row| { - if (std.mem.eql(u8, row[0], "quic") and !try process.quicIncluded(a, exe)) continue; var argv: [8][:0]const u8 = undefined; argv[0] = exe; for (row[1], 1..) |arg, i| argv[i] = arg; @@ -251,7 +249,7 @@ fn forwarding(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // boot puts under it; --shells=3 is three shells, no scratch. try check(rows == @as(usize, if (std.mem.eql(u8, row[0], "shells")) 3 else 2), "{s}: {s}", .{ row[0], index }); } - if (std.mem.eql(u8, row[0], "tcp") or std.mem.eql(u8, row[0], "quic")) + if (std.mem.eql(u8, row[0], "tcp")) try check(has(try local.read("/listeners"), try std.fmt.allocPrint(a, "{s}!127.0.0.1!", .{row[0]})), "{s}: no listener", .{row[0]}); try std.testing.expectEqualStrings(before, try c.read(a, "/index")); try std.testing.expectEqualStrings("initial\n", try c.read(a, "/pane/1/body")); diff --git a/test/process/mounts.zig b/test/process/mounts.zig index 10dc7b5a..8a7fc6fe 100644 --- a/test/process/mounts.zig +++ b/test/process/mounts.zig @@ -9,7 +9,6 @@ const check = process.check; pub const cases = .{ .{ "mounts: --mount at startup reads a peer's panes and its disk, a Save through it lands there, and a path not there is a miss in the log", startup }, - .{ "mounts: a session listening on TCP and QUIC too (-Dquic=true) is mounted over QUIC, saved and got through, its screen read, and unmounted, v4 and v6, detached and in a pty", quic }, .{ "mounts: Mount and Unmount at run time, refused in words when mounted already or in use; a session's /n lists its mounts; a file through a mount opens at startup", runtime }, }; @@ -109,104 +108,3 @@ fn runtime(gpa: std.mem.Allocator, exe: [:0]const u8) !void { defer d.deinit(); try d.files.expect("/pane/1/body", "runtime mounted Save\n"); } - -/// The port of /listeners' `<net>!<host>!<port>` line. -fn port(listeners: []const u8, net: []const u8) !u16 { - var rows = std.mem.tokenizeScalar(u8, listeners, '\n'); - while (rows.next()) |row| { - var parts = std.mem.splitScalar(u8, row, '!'); - if (!std.mem.eql(u8, parts.first(), net)) continue; - _ = parts.next() orelse return error.BadListener; - const p = try std.fmt.parseInt(u16, parts.next() orelse return error.BadListener, 10); - try check(parts.next() == null and p > 0, "listener {s}", .{row}); - return p; - } - return error.NoListener; -} - -fn quic(gpa: std.mem.Allocator, exe: [:0]const u8) !void { - if (!try process.quicIncluded(gpa, exe)) { - std.debug.print("SKIP a build without QUIC (-Dquic=true)\n", .{}); - return; - } - for ([_]bool{ false, true }) |tty| for ([_][:0]const u8{ "127.0.0.1", "::1" }) |host| { - var arena = std.heap.ArenaAllocator.init(gpa); - defer arena.deinit(); - const a = arena.allocator(); - const args = [_][:0]const u8{ - try std.fmt.allocPrintSentinel(a, "--9p-tcp=tcp!{s}!0", .{host}, 0), - try std.fmt.allocPrintSentinel(a, "--9p-quic=quic!{s}!0", .{host}, 0), - }; - var d = try Detached.start(gpa, exe, if (tty) "quic-root" else "server", .{ .args = if (tty) &.{} else &args }); - defer d.deinit(); - var term: ?process.Child = null; - defer if (term) |*t| t.deinit(); - if (tty) term = try d.startTty(exe, "server", &args); - const address = d.abs("pardes-9p-server.sock"); - const unix = try Conn.dial(gpa, address); - defer unix.deinit(gpa); - const listeners = try unix.read(a, "/listeners"); - const tcp_port = try port(listeners, "tcp"); - const quic_port = try port(listeners, "quic"); - try std.testing.expectEqual(@as(usize, 3), std.mem.count(u8, listeners, "\n")); - for ([_][]const u8{ - try std.fmt.allocPrint(a, "unix!{s}\n", .{address}), - try std.fmt.allocPrint(a, "tcp!{s}!{d}\n", .{ host, tcp_port }), - try std.fmt.allocPrint(a, "quic!{s}!{d}\n", .{ host, quic_port }), - }) |row| try check(has(listeners, row), "no {s} in {s}", .{ row, listeners }); - const tcp = try Conn.dialTcp(gpa, host, tcp_port); - defer tcp.deinit(gpa); - const unix_body = try unix.hold("/pane/1/body", 0); - defer unix.clunk(unix_body); - const tcp_body = try tcp.hold("/pane/1/body", 0); - defer tcp.clunk(tcp_body); - var client = try Detached.start(gpa, exe, "client", .{ .root = d.root() }); - defer client.deinit(); - const remote = try Conn.dial(gpa, client.socket()); - defer remote.deinit(gpa); - const control = try remote.newPane(); - try remote.exec(control, try std.fmt.allocPrint(a, "Mount peer quic!{s}!{d}\n", .{ host, quic_port })); - const opened = try remote.look(a, "/n/peer/pane/1/body", control); - const body = try std.fmt.allocPrint(a, "/pane/{d}/body", .{opened}); - try std.testing.expectEqualStrings("initial\n", try remote.read(a, body)); - var payload: std.ArrayList(u8) = .empty; - try payload.appendSlice(a, "saved café λ\n"); - try payload.appendNTimes(a, 'x', 3 * 8192 + 27); - try payload.append(a, '\n'); - try remote.replace(body, payload.items); - try remote.exec(opened, "Save\n"); - try std.testing.expectEqualStrings(payload.items[0..@min(payload.items.len, unix.cl.maxRead())], try unix.readFid(unix_body, 0, 65536)); - try check(std.mem.eql(u8, try tcp.read(a, "/pane/1/body"), payload.items), "TCP reads another body", .{}); - try tcp.replace("/pane/1/body", "TCP to QUIC Get\n"); - try remote.write(try std.fmt.allocPrint(a, "/pane/{d}/ctl", .{opened}), "get\n"); - try std.testing.expectEqualStrings("TCP to QUIC Get\n", try remote.read(a, body)); - try std.testing.expectEqualStrings("TCP to QUIC Get\n", try unix.readFid(unix_body, 0, 65536)); - try std.testing.expectEqualStrings("TCP to QUIC Get\n", try tcp.readFid(tcp_body, 0, 65536)); - // The peer's own screen, whole, over QUIC: its pane's tag, not its - // text, whose place after the body shrank depends on a frame drawn. - const screen_pane = try remote.look(a, "/n/peer/screen", control); - const json = try std.json.parseFromSliceLeaky(std.json.Value, a, try remote.pane(a, screen_pane, "body"), .{}); - const cells = json.object.get("cells").?.array.items; - try std.testing.expectEqual(@as(usize, @intCast(json.object.get("cols").?.integer * json.object.get("rows").?.integer)), cells.len); - var text: std.ArrayList(u8) = .empty; - for (cells) |cell| try text.appendSlice(a, cell.array.items[0].string); - try check(has(text.items, "server.txt Save"), "the peer's screen has no tag", .{}); - var large: std.ArrayList(u8) = .empty; - for (0..20000) |_| try large.appendSlice(a, "normal λ line\n"); - try d.put("large.txt", large.items); - const large_pane = try remote.look(a, try std.fmt.allocPrint(a, "/n/peer/os{s}", .{d.abs("large.txt")}), control); - try check(std.mem.eql(u8, try remote.pane(a, large_pane, "body"), large.items), "the large file is not whole", .{}); - try remote.replace(try std.fmt.allocPrint(a, "/pane/{d}/body", .{large_pane}), "QUIC file saved\n"); - try remote.exec(large_pane, "Save\n"); - try std.testing.expectEqualStrings("QUIC file saved\n", try d.get(a, "large.txt")); - for ([_]u32{ opened, screen_pane, large_pane }) |n| try remote.exec(n, "Del\n"); - try remote.exec(control, "Unmount peer\n"); - const roots = try remote.look(a, "/n", control); - try std.testing.expectEqualStrings("/n/os/\n/n/self/\n", try remote.pane(a, roots, "body")); - try std.testing.expectEqualStrings("TCP to QUIC Get\n", try unix.readFid(unix_body, 0, 65536)); - try std.testing.expectEqualStrings("TCP to QUIC Get\n", try tcp.readFid(tcp_body, 0, 65536)); - // Not checked: a session Looking at its OWN tree through a QUIC - // mount: QUIC is answered on the editor's thread, so that Look waits - // on the loop it runs in (features.txt, "Left as they are"). - }; -} |
