a73x

a200479f

refactor: the new owners' prose says the fact once

a73x   2026-08-29 01:37

Commit message
refactor: the new owners' prose says the fact once

Trimming what the two folds above restated: the rationale each comment keeps
is what fails when it is wrong, not a second telling of the code below it.

src/quic.zig
Old New
@@ -651,14 +651,11 @@ pub fn getNewCidCb(
651 } 651 }
652 652
653 // --------------------------------------------------------------------------- 653 // ---------------------------------------------------------------------------
654 // The client side of the handshake 654 // The client side of the handshake. Two peers dial this daemon — the transport
655 // 655 // in quic_client.zig and the test peer in quic_server.zig, which cannot import
656 // Two peers dial this daemon: the client transport in quic_client.zig and the 656 // it (folder rule 2) — and a drift between them fails the handshake with
657 // test peer in quic_server.zig, which cannot import it (folder rule 2). They 657 // nothing to read but a TLS alert. Each still sets its own key, stream
658 // spelled the whole PSK/ngtcp2 preamble twice, and a drift in either fails the 658 // handlers and idle timeout on what these hand back.
659 // handshake with nothing to read but a TLS alert. What each of them chooses
660 // for itself — its key, its stream handlers, its idle timeout — it still sets
661 // on what these hand back.
662 // --------------------------------------------------------------------------- 659 // ---------------------------------------------------------------------------
663 660
664 /// Identity "mux", the key's bytes, our one ciphersuite: none is a choice. 661 /// Identity "mux", the key's bytes, our one ciphersuite: none is a choice.
@@ -702,9 +699,7 @@ pub fn clientTls(
702 return .{ .ctx = ctx, .ssl = ssl }; 699 return .{ .ctx = ctx, .ssl = ssl };
703 } 700 }
704 701
705 /// Every ngtcp2 callback a client side must install that is the library's 702 /// The ngtcp2 callbacks that are the library's own, not the caller's.
706 /// own rather than the caller's. The caller then sets what IS its own —
707 /// handshake completion, stream events — on the returned struct.
708 pub fn clientCallbacks() c.ngtcp2_callbacks { 703 pub fn clientCallbacks() c.ngtcp2_callbacks {
709 var cbs: c.ngtcp2_callbacks = std.mem.zeroes(c.ngtcp2_callbacks); 704 var cbs: c.ngtcp2_callbacks = std.mem.zeroes(c.ngtcp2_callbacks);
710 cbs.client_initial = c.ngtcp2_crypto_client_initial_cb; 705 cbs.client_initial = c.ngtcp2_crypto_client_initial_cb;
@@ -725,10 +720,9 @@ pub fn clientCallbacks() c.ngtcp2_callbacks {
725 return cbs; 720 return cbs;
726 } 721 }
727 722
728 /// The flow-control window a mux client opens with. `max_idle_timeout` is 723 /// The flow-control window a mux client opens with. `max_idle_timeout` stays
729 /// deliberately left at ngtcp2's default: only the reconnecting transport 724 /// at ngtcp2's default: only the reconnecting transport tunes it, and a
730 /// tunes it, and a fixture that has no reconnect loop must not inherit a 725 /// fixture with no reconnect loop must not inherit a number chosen for one.
731 /// number chosen for one.
732 pub fn clientParams() c.ngtcp2_transport_params { 726 pub fn clientParams() c.ngtcp2_transport_params {
733 var params: c.ngtcp2_transport_params = undefined; 727 var params: c.ngtcp2_transport_params = undefined;
734 c.ngtcp2_transport_params_default_versioned(c.NGTCP2_TRANSPORT_PARAMS_VERSION, &params); 728 c.ngtcp2_transport_params_default_versioned(c.NGTCP2_TRANSPORT_PARAMS_VERSION, &params);
src/server/server.zig
Old New
@@ -1990,25 +1990,18 @@ pub const Server = struct {
1990 1990
1991 /// The verbs whose answer is the DAEMON rather than the connection: 1991 /// The verbs whose answer is the DAEMON rather than the connection:
1992 /// identical bytes for an attached client and for a one-shot `mux d` 1992 /// identical bytes for an attached client and for a one-shot `mux d`
1993 /// tool, so they are answered once here and neither dispatch table 1993 /// tool. Returns false for a verb this owner does not have — an attach,
1994 /// repeats them. Returns false for a verb this owner does not have, and 1994 /// an upgrade, a status_req — which really does depend on who asked.
1995 /// the caller answers it its own way — an attach, an upgrade, or a 1995 /// Written twice before, and the two copies were not the same program.
1996 /// status_req, each of which really does depend on which table asked.
1997 /// 1996 ///
1998 /// They were written twice before, and the two copies were not the same 1997 /// The tables differ only in how an answer LEAVES, which is all
1999 /// program: `sessions_req` had an answerer per table, and every reply
2000 /// spelled its own send. A verb that drifts here answers `mux d stats`
2001 /// differently depending on whether the asker had attached.
2002 ///
2003 /// The two tables differ only in how an answer LEAVES, which is all
2004 /// `replyTo` is: a client has a send queue and never blocks, while an 1998 /// `replyTo` is: a client has a send queue and never blocks, while an
2005 /// observer has no ClientSlot to queue into — `mux d dump`, `mux d 1999 /// observer has none — `mux d dump`, `mux d stats` and `mux d endpoint`
2006 /// stats` and `mux d endpoint` read their one answer and exit. So the 2000 /// read their one answer and exit. So the observer's write is bounded:
2007 /// observer's write is bounded: a dump can be megabytes, it must 2001 /// a dump can be megabytes and must tolerate a short write, and a peer
2008 /// tolerate a short write, and a peer that stops reading must cost this 2002 /// that stops reading costs this reply's budget, not the daemon's loop.
2009 /// reply's budget rather than the daemon's single loop. Past the budget 2003 /// Past the budget the frame is truncated, which is why a failed write
2010 /// the frame is truncated, which is why a failed write drops the 2004 /// drops the connection rather than leave half a frame on it.
2011 /// connection instead of leaving half a frame on it.
2012 fn handleDaemonVerb(self: *Server, p: Peer, frame: proto.Frame) bool { 2005 fn handleDaemonVerb(self: *Server, p: Peer, frame: proto.Frame) bool {
2013 switch (frame.type) { 2006 switch (frame.type) {
2014 .stats_req => { 2007 .stats_req => {