diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-12 17:23:34 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:16 -0300 |
| commit | 9dd6f001c7d5eee987cbd305a79d1b1d011b83f5 (patch) | |
| tree | 2ec5b20565b162b54cdfef9ae5d8fec0e57dfb54 /web | |
| parent | 7a07e24916cd5bc762996d81aa1faf550177cd6f (diff) | |
| download | cloud9-9dd6f001c7d5eee987cbd305a79d1b1d011b83f5.tar.gz cloud9-9dd6f001c7d5eee987cbd305a79d1b1d011b83f5.zip | |
Reserve output space for an async completion plus the already-dispatched synchronous handler. Wait on a condition without the catalogue mutex, preserving cancellation and connection-slot lifetime. Abort HTTP streaming on an upstream error instead of hiding a truncated response.
Reproduced the former failure with concurrent live cafe assets. Add exact-hash load checks with 16 readers, mixed HEAD and 40 interrupted downloads; validate 80 multi-frame responses over 37 live files. All five live sites, mounted 9P browsing, protocol/catalogue/host/HTTP/mux/UI tests and 32 original E2E scenarios pass. Deploy corrected service on sole [::]:8090. See docs/namespace-sites-validation.md.
Diffstat (limited to 'web')
| -rw-r--r-- | web/catalog.zig | 15 | ||||
| -rw-r--r-- | web/httpfs.zig | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/web/catalog.zig b/web/catalog.zig index d375973..977e0ae 100644 --- a/web/catalog.zig +++ b/web/catalog.zig @@ -540,13 +540,15 @@ pub const Catalog = struct { } fn readTask(cat: *Catalog, conn: *Runner.Conn, req: fs.Req, file: Io.File, slot: usize) void { defer file.close(cat.io); + defer { + cat.mutex.lockUncancelable(cat.io); + cat.reads[conn.index][slot] = 0; + cat.mutex.unlock(cat.io); + } var arena = std.heap.ArenaAllocator.init(A); defer arena.deinit(); const b = arena.allocator().alloc(u8, req.size) catch { - cat.mutex.lockUncancelable(cat.io); - defer cat.mutex.unlock(cat.io); - replyError(conn, req.tag, error.OutOfMemory); - cat.reads[conn.index][slot] = 0; + conn.replyAsync(&.{ .tag = req.tag, .status = .err, .ename = "OutOfMemory" }, "") catch {}; return; }; const result = file.readPositional(cat.io, &.{b}, req.off) catch |err| switch (err) { @@ -556,10 +558,7 @@ pub const Catalog = struct { }, else => err, }; - cat.mutex.lockUncancelable(cat.io); - defer cat.mutex.unlock(cat.io); - if (result) |n| conn.reply(&.{ .tag = req.tag }, b[0..n]) else |err| replyError(conn, req.tag, err); - cat.reads[conn.index][slot] = 0; + if (result) |n| conn.replyAsync(&.{ .tag = req.tag }, b[0..n]) catch {} else |err| conn.replyAsync(&.{ .tag = req.tag, .status = .err, .ename = @errorName(err) }, "") catch {}; } fn replyError(conn: *Runner.Conn, tag: u64, err: anyerror) void { const message = switch (err) { diff --git a/web/httpfs.zig b/web/httpfs.zig index 31c4014..479dd09 100644 --- a/web/httpfs.zig +++ b/web/httpfs.zig @@ -313,7 +313,9 @@ fn FS(comptime M: type) type { if (sent >= limit or data.len == 0) break; offset += data.len; const r = try self.readAt(leaf, offset, self.chunk()); - if (r.msg != .rread) break; + // Do not terminate chunked HTTP successfully after a 9P + // error: the client must detect the incomplete response. + if (r.msg != .rread) return error.Upstream; data = r.msg.rread.data; if (data.len == 0) break; } |
