From 16f5d8d761b7677c0b4a07b80b21e82cbee7f97f Mon Sep 17 00:00:00 2001 From: Melanie Riise Date: Fri, 16 Oct 2026 13:18:57 -0700 Subject: [PATCH 1/4] fix(relay): bound auth admission by the handshake deadline Co-authored-by: Claude Fable 5.1 --- doc/bin/relay/auth.md | 5 +- doc/bin/relay/config.md | 6 +- quest/m1/README.md | 1 - quest/m1/drain-cleanup.md | 4 - quest/m1/handshake-admission-deadline.md | 74 -------------- rs/moq-auth/CHANGELOG.md | 1 + rs/moq-auth/src/client.rs | 74 +++++++++++++- rs/moq-cli/CHANGELOG.md | 4 + rs/moq-cli/src/main.rs | 9 +- rs/moq-relay/CHANGELOG.md | 1 + rs/moq-relay/src/auth.rs | 35 ++++--- rs/moq-relay/src/auth/refresh.rs | 2 +- rs/moq-relay/src/cluster.rs | 3 + rs/moq-relay/src/connection.rs | 25 ++++- rs/moq-relay/src/incoming.rs | 12 +++ rs/moq-relay/src/uring.rs | 75 ++++++++++++-- rs/moq-relay/src/web.rs | 57 ++++++++++- .../tests/integration/auth_lifetime.rs | 98 +++++++++++++++++++ rs/moq-tokio/CHANGELOG.md | 4 + rs/moq-tokio/src/listen.rs | 3 +- rs/moq-tokio/src/server.rs | 11 +++ 21 files changed, 384 insertions(+), 120 deletions(-) delete mode 100644 quest/m1/handshake-admission-deadline.md diff --git a/doc/bin/relay/auth.md b/doc/bin/relay/auth.md index 25d59388048..d2c587c8fa3 100644 --- a/doc/bin/relay/auth.md +++ b/doc/bin/relay/auth.md @@ -373,8 +373,9 @@ refusal. Pass the shared `moq_auth::Refusal` in `auth::Error::Refused` to `Admission::refuse`, using the same verified-root rule as an HTTP server. A fixed lease never changes; a `lease::Producer` the application keeps re-checks, updates, and revokes on its own clock. The relay still closes the -session at the grant's `expires`, and an admission left unanswered for ten -seconds is refused. `Admission::attached()` marks a token presented +session at the grant's `expires`, and a connection whose admission is still +unanswered at its `listen.timeout` handshake deadline is closed; a token +presented in band is refused after ten seconds. `Admission::attached()` marks a token presented [in band](#in-band-renewal) for a session already admitted under the same id, so count sessions only on the others. Gateway accept loops can call `Cluster::admit` for the same scoped session as a native connection. See diff --git a/doc/bin/relay/config.md b/doc/bin/relay/config.md index b6c863dafce..6b8cc53ce7b 100644 --- a/doc/bin/relay/config.md +++ b/doc/bin/relay/config.md @@ -40,8 +40,10 @@ solicit = false # Decline MoQ Solicit, so peers may announc epoch = false # Decline MoQ Epoch, so routes over moq-transport carry no epoch (draft 17+). ``` -`timeout` bounds the whole handshake, transport through MoQ SETUP, so a peer -that connects and never speaks is closed instead of held open by keep-alives. +`timeout` bounds the whole handshake, transport through MoQ SETUP and auth +admission, so a peer that connects and never speaks, or whose admission never +gets an answer, is closed instead of held open by keep-alives. An HTTP read's +admission is bounded by the same value from the request's arrival. A setting no configured listener reads stops startup rather than being ignored. A stream-only relay refuses `preferred_v4`, `preferred_v6`, and `lb_id` (or `load_balancer`), which diff --git a/quest/m1/README.md b/quest/m1/README.md index b644de46934..40436469bc6 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -90,7 +90,6 @@ lands before the cut. - [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the playout target is default in both languages; a manual browser proof and a native trace replay remain - [A/V clock](/quest/m1/av-clock.md) - the audio playhead drives Sync.reference while audio plays, through per-track sync handles - [Publish channel count](/quest/m1/publish-audio-channel-count.md) - forcing a channel count on an Audio.Capture stops costing the subscriber gaps of silence, and the media fixture's cold-start audio-tone flake is fixed at its cause -- [Handshake deadline covers admission](/quest/m1/handshake-admission-deadline.md) - `listen.timeout` bounds a connection through auth admission on both listeners, replacing the hardcoded admission timeout - [Restart reset](/quest/m1/stateless-reset-key.md) - a relay restarted with the same `listen.reset_key` stateless-resets its predecessor's connections, so clients reconnect within an RTT instead of the idle timeout - [Drain cleanup](/quest/m1/drain-cleanup.md) - sessions force-closed at the drain deadline record their lease end and bytes before the relay or CLI exits, while unfinished handshakes stay bounded - [GOAWAY coverage](/quest/m1/goaway-coverage.md) - every IETF request stream handles GOAWAY, a closed control stream is a violation, and the draft-18 cutoff is honored diff --git a/quest/m1/drain-cleanup.md b/quest/m1/drain-cleanup.md index 1629b37e21b..cb9461ccb6f 100644 --- a/quest/m1/drain-cleanup.md +++ b/quest/m1/drain-cleanup.md @@ -85,7 +85,3 @@ process exits relative to the deadline. Public API: possibly a small shared drain helper in `moq_relay::shutdown`. Wire: none. - -## Related - -- [Handshake deadline covers admission](/quest/m1/handshake-admission-deadline.md) - bounds pending admissions, which the drain deadline must keep cutting diff --git a/quest/m1/handshake-admission-deadline.md b/quest/m1/handshake-admission-deadline.md deleted file mode 100644 index 3e2de3bf143..00000000000 --- a/quest/m1/handshake-admission-deadline.md +++ /dev/null @@ -1,74 +0,0 @@ -# [M] The handshake deadline covers admission - -## Goal - -`listen.timeout` bounds a connection from its first packet through auth -admission, on both the tokio and io_uring listeners. A peer that finishes MoQ -SETUP can no longer hold a connection open past the deadline while auth is -pending, and admission has no separate hardcoded bound. - -## Plan - -Decided 2026-10-13 (from #5244's review, where Codex asked to keep enforcing -the deadline while authorization runs): - -- ✅ One deadline through admission. The handshake deadline that already - bounds transport, SETUP and SETUP OK also races `Auth::admit` in - `rs/moq-relay/src/connection.rs` and `rs/moq-relay/src/uring.rs`. On - expiry the session closes with the MoQ timeout code, as for the other - phases. -- `ADMIT_TIMEOUT` (10 s in `rs/moq-relay/src/auth.rs`) stops bounding - admission; a fixed cap that only throws is not a contract. `listen.timeout - = "0"` then waits forever through admission too, as it documents. - Grant renewal in `auth/refresh.rs` keeps its own bound for now; it runs - after the handshake, so `listen.timeout` does not apply. -- Not chosen: keep `ADMIT_TIMEOUT` as an inner cap; a separate - `auth.timeout` config with `listen.timeout` still ending at SETUP. - -Start after #5244 (io_uring handshake deadline) merges, since it adds the -io_uring deadline this extends. - -Gaps found in this plan's review, to settle with the maintainer at start: - -- Dropping the shared cap leaves the other `Auth::admit` callers unbounded: - WebSocket admission before the upgrade (`websocket.rs`), HTTP admission - (`admit_http` in `web.rs`), `serve_client` in `rs/moq-cli/src/main.rs` - for `moq --listen`, and the public `Auth::admit` and `Cluster::admit` for - embedders. Recommendation, following the decision above: the web callers - race the web listener's timeout, which is the same `listen.timeout`; - `moq --listen` races its own listener's `listen.timeout`; and `Auth::admit` - and `Cluster::admit` document that they wait on the decider and the caller - owns the deadline. -- `moq_auth::Client` sets a 10 s reqwest timeout on every request - (`rs/moq-auth/src/client.rs`), so an HTTP auth server answering `connect` - after 10 s is still refused. Only `connect` drops that fixed bound and - inherits the caller's deadline. `attach` (in-band AUTH, which shares the - `connect` path), `revalidate` and `end` run after the handshake and keep - theirs, like grant renewal, so a stalled server cannot pile up requests. -- `moq_tokio::server::Request` keeps its handshake deadline private and - applies it only in `ok()`, after admission, so `connection.rs` cannot race - admission against it today. Recommendation: a public `Request` method that - bounds a future by what remains of the deadline, keeping the deadline itself - private, mirrored on the io_uring request if it has the same shape. Do not - start a fresh timeout at admission; the deadline runs from the first packet. - -Race inside the task that owns the admission, or cancel it, so an expired -deadline does not leave admission work running detached. - -Tests on controlled time for each caller, the embedded decider and an HTTP -auth server: an admission that never answers closes at the deadline, one -answered just inside it (past 10 s for the HTTP server) is admitted, and -`"0"` waits. At the deadline the HTTP server sees its `connect` request -dropped, so expired admissions leave no in-flight requests behind. An -`attach` to a stalled server is still refused at its bound. -Update `doc/bin/relay/config.md`, which says the deadline covers -"transport through MoQ SETUP", and `doc/bin/relay/auth.md`, which promises -that an embedded admission left unanswered for ten seconds is refused; the -embedder now owns that deadline. Note the behavior change for slow auth -servers in the `moq-relay` and `moq-auth` changelogs. - -Public API: a new `moq_tokio::server::Request` method to bound admission by -the handshake deadline. `Auth::admit`, `Cluster::admit` and -`moq_auth::Client::connect` keep their signatures but no longer time out on -their own. Config: -`listen.timeout` now includes admission. Wire: none. diff --git a/rs/moq-auth/CHANGELOG.md b/rs/moq-auth/CHANGELOG.md index db4e05be548..6e6f716c453 100644 --- a/rs/moq-auth/CHANGELOG.md +++ b/rs/moq-auth/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [**breaking**] Publish and subscribe roles in claims, grants, and permissions now carry `Access { path, rate }`. Optional positive bitrate caps survive signing, authorization, and grant serialization; key scopes refuse them. Gateway embedders must enforce caps or refuse capped grants before admitting media. - Auth requests distinguish `webtransport` from native `quic`. Upgrade auth servers before relays: older servers reject the new value. Rust and JavaScript auth parsers now map future transport names to `unknown`. +- `Client::connect` no longer times out on its own: the caller's deadline bounds it, and dropping the future drops the request. `attach`, revalidate, and end keep a ten-second bound, reported as `Error::Unavailable`. ## [0.2.1](https://github.com/moq-dev/moq/compare/moq-auth-v0.2.0...moq-auth-v0.2.1) - 2026-10-03 diff --git a/rs/moq-auth/src/client.rs b/rs/moq-auth/src/client.rs index 0a6cee903d3..ff2c5232cdc 100644 --- a/rs/moq-auth/src/client.rs +++ b/rs/moq-auth/src/client.rs @@ -32,7 +32,9 @@ impl Client { /// caller's client identity and roots; `unix://` speaks HTTP over the socket at /// the URL's path. Anything else is refused here rather than at the first session. pub fn new(url: Url, tls: Option) -> crate::Result { - let builder = reqwest::Client::builder().timeout(TIMEOUT); + // No client-wide timeout: `connect` runs under its caller's deadline, and the + // requests that run after the handshake are bounded one by one. + let builder = reqwest::Client::builder(); let (builder, url) = match url.scheme() { "http" => { @@ -71,6 +73,11 @@ impl Client { /// Admit a session: POST `connect`, validate the reply, and return the lease the /// session holds. The session reports its end and totals through [`lease::Consumer::close`] /// or drop; credential expiry alone never reports that the connection ended. + /// + /// Waits on the server for as long as the caller does: the connection's handshake + /// deadline is the bound, and dropping the future drops the request. Every later + /// request for the session ([`attach`](Self::attach), revalidate, end) is bounded + /// on its own, since nothing else bounds it. pub async fn connect(&self, request: Request) -> crate::Result { let context = Context::new(request.clone(), self.identity.clone()); admit(self.clone(), request, context).await @@ -253,11 +260,17 @@ impl Post for Client { } /// Admit a session through `server` and spawn the driver behind its lease. +/// +/// The connection's own `connect` runs under the caller's deadline; an attached +/// credential arrives after the handshake, so its request is bounded here. async fn admit(server: S, mut request: Request, context: Context) -> crate::Result { request.event = Event::Connect; let admission = context.admitting()?; - let grant = ask(&server, &request).await?; + let grant = match context.owner { + true => ask(&server, &request).await?, + false => bounded(ask(&server, &request)).await?, + }; if context.connection.lifecycle.read().ended.is_some() { return Err(Error::Refused(Default::default())); } @@ -289,6 +302,16 @@ async fn ask(server: &S, request: &Request) -> crate::Result { Ok(grant) } +/// Finish a request that nothing else bounds within [`TIMEOUT`], or report the +/// server as unavailable, so a stalled server cannot pile up requests. +async fn bounded(request: impl Future>) -> crate::Result { + moq_clock::timeout(TIMEOUT, request).await.unwrap_or_else(|_| { + Err(Error::Unavailable(format!( + "the auth server did not answer within {TIMEOUT:?}" + ))) + }) +} + /// `url` without its userinfo, query, or fragment, any of which may carry a credential. fn redact(url: &Url) -> String { let mut url = url.clone(); @@ -324,7 +347,7 @@ impl Driver { bytes, }; // The session is already gone; nothing to do with a failure but say so. - if let Err(err) = self.server.post_end(&request).await { + if let Err(err) = bounded(self.server.post_end(&request)).await { tracing::warn!(id = %request.id, %err, "failed to report the session end"); } } @@ -395,7 +418,7 @@ impl Driver { let server = self.server.clone(); let mut request = self.request.clone(); request.event = Event::Revalidate; - Box::pin(async move { ask(&server, &request).await }) + Box::pin(async move { bounded(ask(&server, &request)).await }) } } @@ -612,6 +635,49 @@ mod tests { ); } + /// `connect` waits as long as its caller does, so a server answering past the + /// fixed bound still admits the session. An attached credential arrives after the + /// handshake, which nothing else bounds, so it keeps the bound. + #[tokio::test(start_paused = true)] + async fn connect_waits_for_a_slow_server_but_attach_does_not() { + #[derive(Clone)] + struct Slow(Script); + impl Post for Slow { + async fn post(&self, request: &Request) -> crate::Result { + tokio::time::sleep(TIMEOUT + Duration::from_secs(1)).await; + self.0.post(request).await + } + async fn post_end(&self, request: &Request) -> crate::Result<()> { + self.0.post_end(request).await + } + } + let script = Script::new(Log::default(), |_| Some(Ok(grant(None, None)))); + let server = Slow(script.clone()); + + let start = tokio::time::Instant::now(); + let owner = match admit( + server.clone(), + request(), + Context::new(request(), script.identity.clone()), + ) + .await + { + Ok(owner) => owner, + Err(err) => panic!("connect gave up on a slow server: {err}"), + }; + assert_eq!(start.elapsed(), TIMEOUT + Duration::from_secs(1)); + + let mut attached = request(); + attached.query = Some("jwt=replacement".into()); + let context = owner.context().unwrap().attach(&attached, &script.identity).unwrap(); + let start = tokio::time::Instant::now(); + let Err(err) = admit(server, attached, context).await else { + panic!("an attached credential waited past its bound"); + }; + assert!(matches!(err, Error::Unavailable(_)), "{err:?}"); + assert_eq!(start.elapsed(), TIMEOUT); + } + #[tokio::test] async fn a_withdrawn_attachment_lands_its_revalidate_before_end() { #[derive(Clone)] diff --git a/rs/moq-cli/CHANGELOG.md b/rs/moq-cli/CHANGELOG.md index 0291c228f3d..460d255a616 100644 --- a/rs/moq-cli/CHANGELOG.md +++ b/rs/moq-cli/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- `moq --listen` bounds auth admission by the listener's `listen.timeout` handshake deadline instead of a fixed ten seconds. + ## [0.14.2](https://github.com/moq-dev/moq/compare/moq-cli-v0.14.1...moq-cli-v0.14.2) - 2026-10-06 ### Other diff --git a/rs/moq-cli/src/main.rs b/rs/moq-cli/src/main.rs index 10005ec4e31..f4c8323c2cf 100644 --- a/rs/moq-cli/src/main.rs +++ b/rs/moq-cli/src/main.rs @@ -188,9 +188,12 @@ impl Serving { let origin = &self.cluster.origin; let directions = self.directions; let auth_request = moq_relay::auth::request_for(&self.auth, &request); - let lease = match self.auth.admit(auth_request).await { - Ok(lease) => lease, - Err(err) => { + // The listener's handshake deadline covers admission; `within` closes a session + // it gives up on with the timeout code. + let lease = match request.within(self.auth.admit(auth_request)).await { + Err(err) => return Err(anyhow::Error::new(err).context("admission timed out")), + Ok(Ok(lease)) => lease, + Ok(Err(err)) => { let status = axum::http::StatusCode::from(&err); let reject = match status { axum::http::StatusCode::UNAUTHORIZED => moq_tokio::server::Reject::Unauthorized, diff --git a/rs/moq-relay/CHANGELOG.md b/rs/moq-relay/CHANGELOG.md index ddb46ce92b8..42ac731a029 100644 --- a/rs/moq-relay/CHANGELOG.md +++ b/rs/moq-relay/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [**breaking**] Auth token roles now carry `moq_auth::Access`. Every capped grant is refused until its transport enforces caps, including in-band additions and revalidation. HTTP fetch and announcement endpoints always refuse per-connection caps. Gateway embedders must enforce caps or refuse them. - Auth requests distinguish `webtransport` from native `quic`. Upgrade auth servers before relays: older servers reject the new value. Rust and JavaScript auth parsers now map future transport names to `unknown`. +- `listen.timeout` bounds auth admission as part of the handshake, replacing the fixed ten-second admission timeout, so an auth server answering `connect` late is admitted within the deadline and `"0"` waits through admission too. HTTP reads bound admission by the web listener's timeout. `Auth::admit` and `Cluster::admit` no longer time out on their own; the caller owns the deadline. In-band token verification keeps its ten-second bound. ## [0.17.2](https://github.com/moq-dev/moq/compare/moq-relay-v0.17.1...moq-relay-v0.17.2) - 2026-10-06 diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index 315d6081ab2..a6ddecf7ab3 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -16,10 +16,10 @@ use serde_with::{OneOrMany, serde_as}; use tokio::sync::{mpsc, oneshot}; use url::Url; -/// The longest a decider may take to answer an admission, the bound -/// `moq_auth::Client` puts on a server, so a stalled decider refuses rather -/// than parks the session behind it. -const ADMIT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); +/// The longest a decider may take to verify a token presented in band. A +/// connection's admission has no bound of its own: it runs under the listener's +/// handshake deadline, which a token arriving after the handshake does not. +const ATTACH_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); /// Where every session's grant comes from. Exactly one of `url` and the public /// patterns is set; [`validate`](Self::validate) refuses anything else. @@ -780,15 +780,24 @@ enum Decider { impl Decider { fn spawn(self, mut admissions: Admissions) { tokio::spawn(async move { - while let Some(admission) = admissions.next().await { + while let Some(mut admission) = admissions.next().await { match &self { Self::Server(client) => { let client = client.clone(); // A panic drops the admission, which answers it as unavailable. tokio::spawn(moq_tokio::panic::isolate(async move { - let lease = match &admission.connection { - Some(connection) => client.attach(connection, admission.request.clone()).await, - None => client.connect(admission.request.clone()).await, + let ask = async { + match &admission.connection { + Some(connection) => client.attach(connection, admission.request.clone()).await, + None => client.connect(admission.request.clone()).await, + } + }; + // The relay stopped waiting (its handshake deadline passed): drop the + // request to the server, so an expired admission leaves nothing in flight. + let lease = tokio::select! { + biased; + () = admission.reply.closed() => return, + lease = ask => lease, }; match lease { Ok(lease) => admission.grant(lease), @@ -887,6 +896,11 @@ impl Auth { } /// Admit a session: the lease it holds, carrying the scope the origin applies. + /// + /// Waits on the decider for as long as the caller does. The caller owns the + /// deadline: a listener bounds it with the connection's handshake deadline + /// ([`moq_tokio::server::Request::within`]), and dropping the future withdraws + /// the admission from the decider. pub async fn admit(&self, request: Request) -> Result { // Build the token from the grant the admission checked: re-reading it could // pick up an update that skipped the check. @@ -902,10 +916,7 @@ impl Auth { async fn decide(&self, request: Request) -> Result<(lease::Consumer, Grant), Error> { let answer = self.submit(request, None)?; - let answered = moq_clock::timeout(ADMIT_TIMEOUT, answer) - .await - .map_err(|_| timed_out())?; - answered_with(answered) + answered_with(answer.await) } /// Queue one admission for the decider, returning its pending answer. diff --git a/rs/moq-relay/src/auth/refresh.rs b/rs/moq-relay/src/auth/refresh.rs index 1e03db153f4..5f2f3f602a5 100644 --- a/rs/moq-relay/src/auth/refresh.rs +++ b/rs/moq-relay/src/auth/refresh.rs @@ -242,7 +242,7 @@ impl Refresh { self.waiting.push_back(Waiting { request, facts, - deadline: moq_clock::now() + super::ADMIT_TIMEOUT, + deadline: moq_clock::now() + super::ATTACH_TIMEOUT, }); self.dispatch(); } diff --git a/rs/moq-relay/src/cluster.rs b/rs/moq-relay/src/cluster.rs index 1f64f92134e..685e4d78c8a 100644 --- a/rs/moq-relay/src/cluster.rs +++ b/rs/moq-relay/src/cluster.rs @@ -1259,6 +1259,9 @@ impl Cluster { } /// Admit a gateway session and scope both origin directions from its grant. + /// + /// Waits on the decider for as long as the caller does; the caller owns the + /// deadline, as for [`auth::Auth::admit`]. pub async fn admit(&self, auth: &auth::Auth, request: moq_auth::Request) -> Result { let result = async { if !matches!(request.event, moq_auth::Event::Connect) { diff --git a/rs/moq-relay/src/connection.rs b/rs/moq-relay/src/connection.rs index e2624925964..72d1d1f1404 100644 --- a/rs/moq-relay/src/connection.rs +++ b/rs/moq-relay/src/connection.rs @@ -87,8 +87,14 @@ impl Connection { async fn serve(request: R, lifecycle: &Lifecycle) -> anyhow::Result<()> { // Abandoned at the drain deadline, so the deadline bounds this task and its - // socket like it bounds a session. - let admitted = lifecycle.admit(request.admission(&lifecycle.auth)).await; + // socket like it bounds a session, and at the handshake deadline, so a peer + // cannot hold the connection open behind a decision that never comes. + // Boxed: the admission future is large, and nesting it inline overflows debug stacks. + let admitted = request + .within(Box::pin(lifecycle.admit(request.admission(&lifecycle.auth)))) + .await + .inspect_err(|_| lifecycle.cluster.refusals.record(Refusal::Unavailable)) + .map_err(|err| err.context("admission timed out"))?; let (admitted, registration) = match admitted { Ok(admitted) => admitted, Err(err) => { @@ -231,6 +237,7 @@ impl Lifecycle { } /// Keep the connection span across a worker-to-shared-runtime handoff and return panics to its owner. + /// Dropping the returned future aborts the task, so it never outlives its connection. #[cfg(all(target_os = "linux", feature = "_uring"))] pub(crate) async fn shared( &self, @@ -238,9 +245,17 @@ impl Lifecycle { task: impl std::future::Future + Send + 'static, ) -> anyhow::Result { use anyhow::Context as _; - runtime - .spawn(moq_tokio::panic::isolate(task).instrument(self.span.clone())) - .await + + struct AbortOnDrop(tokio::task::AbortHandle); + impl Drop for AbortOnDrop { + fn drop(&mut self) { + self.0.abort(); + } + } + + let task = runtime.spawn(moq_tokio::panic::isolate(task).instrument(self.span.clone())); + let _abort = AbortOnDrop(task.abort_handle()); + task.await .context("connection task failed")? .ok_or_else(|| anyhow::anyhow!("connection task panicked")) } diff --git a/rs/moq-relay/src/incoming.rs b/rs/moq-relay/src/incoming.rs index e00f7cbff69..86ea3e3d492 100644 --- a/rs/moq-relay/src/incoming.rs +++ b/rs/moq-relay/src/incoming.rs @@ -47,6 +47,9 @@ pub trait Sealed: Sized { /// What the auth decider is asked about this session. fn admission(&self, auth: &auth::Auth) -> moq_auth::Request; + /// Finish `work` before the handshake deadline, closing the session if it passes. + async fn within(&self, work: impl std::future::Future) -> anyhow::Result; + /// Refuse the session with the admission's HTTP-style status. async fn reject(self, status: http::StatusCode); @@ -87,6 +90,10 @@ impl Sealed for moq_tokio::server::Request { auth::request_for(auth, self) } + async fn within(&self, work: impl std::future::Future) -> anyhow::Result { + Ok(moq_tokio::server::Request::within(self, work).await?) + } + async fn reject(self, status: http::StatusCode) { let reject = match status { http::StatusCode::UNAUTHORIZED => moq_tokio::server::Reject::Unauthorized, @@ -154,6 +161,11 @@ impl Sealed for Accepted { auth::request_for_setup(auth, &self.handshake, self.transport) } + /// No listener deadline: whoever owns the transport bounds the handshake. + async fn within(&self, work: impl std::future::Future) -> anyhow::Result { + Ok(work.await) + } + async fn reject(self, status: http::StatusCode) { self.handshake.close(match status { http::StatusCode::UNAUTHORIZED | http::StatusCode::FORBIDDEN => moq_net::Error::Unauthorized, diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index e391b6eafec..a33d429585d 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -776,10 +776,17 @@ async fn serve_request( auth_request.alpn = alpn.clone(); auth_request.tls = identity.as_ref().and_then(crate::auth::peer); let admission = lifecycle.clone(); - let (admitted, registration) = match lifecycle - .shared(&serve.tokio, async move { admission.admit(auth_request).await }) - .await? - { + // The handshake deadline covers admission too, so a peer cannot hold the connection + // open behind a decision that never comes. Dropping the shared task withdraws it. + let decided = deadline + .bound(lifecycle.shared(&serve.tokio, async move { admission.admit(auth_request).await })) + .await + .inspect_err(|err| { + if matches!(err.downcast_ref::(), Some(moq_net::Error::Timeout)) { + serve.cluster.refusals.record(crate::refusals::Refusal::Unavailable); + } + })?; + let (admitted, registration) = match decided { Ok(admitted) => admitted, Err(err) => { // The status is what separates "your credential is bad" from "the auth @@ -909,8 +916,7 @@ mod tests { ); } - /// An auth decision still pending at the drain deadline is abandoned then, - /// although worker teardown only detaches the task awaiting it. + /// An auth decision still pending at the drain deadline is abandoned by then. #[tokio::test] async fn pending_admission_is_abandoned_at_the_deadline() { let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); @@ -965,4 +971,61 @@ mod tests { running.await.unwrap().unwrap(); connecting.abort(); } + + /// `listen.timeout` bounds admission on the io_uring listener too: a decision + /// that never comes is abandoned at the handshake deadline. + #[tokio::test] + async fn pending_admission_is_abandoned_at_the_handshake_deadline() { + let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); + if let Err(moq_uring::Error::Unsupported(reason)) = moq_uring::Worker::new(Default::default()) + && std::env::var_os("MOQ_STRICT").is_none() + { + eprintln!("skipping io_uring relay test: {reason}"); + return; + } + + let dir = tempfile::tempdir().unwrap(); + let key = rcgen::KeyPair::generate().unwrap(); + let cert = rcgen::CertificateParams::new(vec!["localhost".to_string()]) + .unwrap() + .self_signed(&key) + .unwrap(); + let (cert_path, key_path) = (dir.path().join("cert.pem"), dir.path().join("key.pem")); + std::fs::write(&cert_path, cert.pem()).unwrap(); + std::fs::write(&key_path, key.serialize_pem()).unwrap(); + + let timeout = std::time::Duration::from_secs(1); + let mut config = crate::Config::default(); + config.listen.bind = Some("127.0.0.1:0".parse().unwrap()); + config.listen.tls.cert = vec![cert_path]; + config.listen.tls.key = vec![key_path]; + config.listen.timeout = Some(timeout); + config.runtime.workers = Some(1); + config.runtime.pin = false; + config.runtime.io_uring = true; + config.drain_timeout = std::time::Duration::from_millis(100); + let mut relay = crate::Relay::load(config).await.unwrap().with_signals(false); + let port = relay.addr().unwrap().port(); + let mut admissions = relay.admissions().unwrap(); + let trigger = relay.shutdown_trigger().clone(); + let running = tokio::spawn(relay.run()); + + let mut client = moq_tokio::connect::Config::default(); + client.tls.insecure = Some(true); + client.once = Some(true); + client.bind = Some("127.0.0.1:0".parse().unwrap()); + let url: url::Url = format!("moql://127.0.0.1:{port}/deadline").parse().unwrap(); + let client = client.init(Default::default()).unwrap(); + let connecting = tokio::spawn(async move { client.with_reconnect(false).connect(url).established().await }); + let mut admission = admissions.next().await.unwrap(); + + // The handshake deadline is an io_uring timer, which a paused tokio clock cannot + // advance, so this waits out the real second with nobody answering. + tokio::time::timeout(timeout * 5, admission.abandoned()) + .await + .expect("the admission outlived the handshake deadline"); + trigger.start(); + running.await.unwrap().unwrap(); + connecting.abort(); + } } diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index ce57894e5d3..5bc534edd7c 100644 --- a/rs/moq-relay/src/web.rs +++ b/rs/moq-relay/src/web.rs @@ -984,11 +984,16 @@ async fn admit_http( request.server_name = request_host(uri, headers); request.remote = Some(remote.0); request.tls = mtls.and_then(|Extension(MtlsPeer(identity))| auth::peer(&identity)); - let lease = state - .auth - .admit(request) - .await - .inspect_err(|err| state.cluster.refusals.record_auth(err))?; + // The listener's timeout bounds admission as it bounds the request headers. An + // HTTP read has no handshake deadline to inherit, so the bound starts here. + let admit = state.auth.admit(request); + let lease = match state.timeout { + Some(timeout) => moq_clock::timeout(timeout, admit) + .await + .unwrap_or_else(|_| Err(auth::Error::Unavailable("the admission timed out".into()))), + None => admit.await, + } + .inspect_err(|err| state.cluster.refusals.record_auth(err))?; let token = lease.token(); let Some(origin) = state.cluster.subscriber(token) else { state.cluster.refusals.record(crate::refusals::Refusal::Forbidden); @@ -1937,6 +1942,48 @@ mod tests { serving.abort(); } + /// An HTTP read's admission is bounded by the listener's timeout, like its request + /// headers: a decision that never comes answers 502 once the timeout passes. Real + /// sockets, so this runs on the wall clock and bounds the answer from below. + #[tokio::test] + async fn an_unanswered_http_admission_is_refused_at_the_timeout() { + use tokio::io::{AsyncReadExt, AsyncWriteExt}; + + let timeout = std::time::Duration::from_millis(200); + let mut config = Config::default(); + config.http.listen = Some("127.0.0.1:0".parse().unwrap()); + // Held and never answered: the decider that never decides. + let (auth, _admissions) = crate::auth::Auth::embedded("test"); + let cluster = cluster::Cluster::new(crate::cluster::Options::default()).unwrap(); + let dir = TempDir::new().unwrap(); + let (_, cert, _) = make_certs(&dir); + let certificates = moq_tokio::tls::Certificates::from_pem(&std::fs::read(&cert).unwrap()).unwrap(); + let web = Web::new(auth, cluster, certificates, config) + .with_timeout(Some(timeout)) + .bind() + .unwrap(); + let http = web.addrs().http.expect("the HTTP listener is configured"); + let routes = web.routes(); + let serving = tokio::spawn(web.serve(routes)); + + let mut tcp = tokio::net::TcpStream::connect(http).await.unwrap(); + let start = std::time::Instant::now(); + tcp.write_all(b"GET /announced HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n") + .await + .unwrap(); + + let mut response = Vec::new(); + tokio::time::timeout(std::time::Duration::from_secs(10), tcp.read_to_end(&mut response)) + .await + .expect("the unanswered admission held the request open") + .ok(); + let response = String::from_utf8_lossy(&response); + assert!(response.starts_with("HTTP/1.1 502 "), "{response}"); + assert!(start.elapsed() >= timeout, "refused before the timeout"); + + serving.abort(); + } + /// Confirm `SetConnectionExtensions` injects the marker into request extensions /// when a peer cert was presented, and leaves them untouched otherwise. #[tokio::test] diff --git a/rs/moq-relay/tests/integration/auth_lifetime.rs b/rs/moq-relay/tests/integration/auth_lifetime.rs index 7de653ee3dc..9f158355a0b 100644 --- a/rs/moq-relay/tests/integration/auth_lifetime.rs +++ b/rs/moq-relay/tests/integration/auth_lifetime.rs @@ -1392,6 +1392,104 @@ async fn a_relay_without_an_auth_source_is_decided_by_the_embedder() { .expect("relay exited with an error"); } +/// A relay deciding admissions in process, listening on TCP with `timeout` as its +/// handshake deadline, and a client connecting to it. +async fn connect_through_embedded_admission( + timeout: Duration, +) -> ( + Relay, + auth::Admissions, + tokio::task::JoinHandle>, +) { + let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); + let mut config = Config::default(); + config.listen.tcp.bind = Some("127.0.0.1:0".parse().expect("parse addr")); + config.listen.timeout = Some(timeout); + config.drain_timeout = Duration::from_millis(100); + let mut relay = Relay::load(config).await.expect("load relay"); + let port = relay.tcp_addr().expect("TCP listener bound").port(); + let admissions = relay.admissions().expect("an empty [auth] hands over the admissions"); + let url = room_url("tcp", port); + let connecting = tokio::spawn(async move { client().with_reconnect(false).connect(url).established().await }); + (relay, admissions, connecting) +} + +/// `listen.timeout` bounds admission as part of the handshake: a decision that never +/// comes closes the connection at the deadline, not after a fixed cap of its own. +#[tokio::test] +async fn an_unanswered_admission_closes_at_the_handshake_deadline() { + let (relay, mut admissions, connecting) = connect_through_embedded_admission(Duration::from_secs(1)).await; + let trigger = relay.shutdown_trigger().clone(); + let running = tokio::spawn(relay.run()); + let admission = admissions.next().await.expect("the admission is asked"); + + // Only timers decide what follows: the deadline passes with nobody answering. + tokio::time::pause(); + tokio::time::advance(Duration::from_secs(2)).await; + tokio::time::resume(); + // The close reaches the client over loopback within moments; the old fixed cap + // would have held the connection for another eight seconds. + let connecting = tokio::time::timeout(TIMEOUT, connecting) + .await + .expect("the client never settled") + .expect("client task"); + if let Ok(connection) = connecting { + tokio::time::timeout(Duration::from_secs(3), connection.closed()) + .await + .expect("the connection outlived the handshake deadline") + .expect_err("closed as refused, not cleanly"); + } + // A decision now has nobody to tell. + drop(admission); + + trigger.start(); + tokio::time::timeout(TIMEOUT, running) + .await + .expect("run returned after the trigger") + .expect("relay task panicked") + .expect("relay exited with an error"); +} + +/// Admission has no bound but the handshake deadline: a decision past the old +/// ten-second cap still admits the session, under a deadline or with `"0"`, which +/// sets none. The wait stays under the transport's keep-alive, which a longer jump +/// of the paused clock would trip on its own. +#[tokio::test] +async fn a_late_decision_within_the_deadline_admits() { + let wait = Duration::from_secs(11); + for timeout in [Duration::from_secs(30), Duration::ZERO] { + let (relay, mut admissions, connecting) = connect_through_embedded_admission(timeout).await; + let trigger = relay.shutdown_trigger().clone(); + let running = tokio::spawn(relay.run()); + let admission = admissions.next().await.expect("the admission is asked"); + + tokio::time::pause(); + tokio::time::advance(wait).await; + tokio::time::resume(); + admission.grant(moq_auth::lease::Consumer::fixed(grant(Duration::from_secs(3600)))); + let connection = tokio::time::timeout(TIMEOUT, connecting) + .await + .expect("the late decision never reached the client") + .expect("client task") + .unwrap_or_else(|err| panic!("{timeout:?}: refused after {wait:?}: {err}")); + // Admitted, so the session stays up; a refusal would have closed it by now. + assert!( + tokio::time::timeout(Duration::from_secs(1), connection.closed()) + .await + .is_err(), + "{timeout:?}: closed after the decision {wait:?} in" + ); + drop(connection); + + trigger.start(); + tokio::time::timeout(TIMEOUT, running) + .await + .expect("run returned after the trigger") + .expect("relay task panicked") + .expect("relay exited with an error"); + } +} + /// The next route and whether it is active. async fn next_update(announced: &mut moq_net::announce::Consumer) -> Option<(moq_net::announce::Announce, bool)> { match announced.next().await? { diff --git a/rs/moq-tokio/CHANGELOG.md b/rs/moq-tokio/CHANGELOG.md index 1a9b8ba0216..c37a54f514d 100644 --- a/rs/moq-tokio/CHANGELOG.md +++ b/rs/moq-tokio/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `server::Request::within` finishes a future, such as admitting the session, within what remains of the handshake deadline, closing the session with the timeout code otherwise. + ## [0.19.23](https://github.com/moq-dev/moq/compare/moq-tokio-v0.19.22...moq-tokio-v0.19.23) - 2026-10-06 ### Fixed diff --git a/rs/moq-tokio/src/listen.rs b/rs/moq-tokio/src/listen.rs index 0acf2667450..17de4ac0f5d 100644 --- a/rs/moq-tokio/src/listen.rs +++ b/rs/moq-tokio/src/listen.rs @@ -152,7 +152,8 @@ pub struct Config { pub extensions: moq_net::setup::Extensions, /// Maximum time for one accepted connection to finish its handshake: the - /// QUIC, WebTransport, WebSocket, or qmux one, then the MoQ SETUP, through + /// QUIC, WebTransport, WebSocket, or qmux one, then the MoQ SETUP, whatever the + /// server runs under [`crate::server::Request::within`] (admission, say), through /// [`crate::server::Request::ok`]. Defaults to 10 seconds; set to 0 to wait forever. /// /// A peer that connects and then never speaks would otherwise hold its diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 2125112a93d..779e4cc7e52 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -1786,6 +1786,17 @@ impl Request { self.quic.as_ref() } + /// Finish `work` before what remains of the handshake deadline, or close the + /// session with the timeout code and return [`moq_net::Error::Timeout`]. + /// + /// Admitting the session is the caller's part of the handshake, so the same + /// `listen.timeout` that bounds the transport and SETUP bounds it too; a peer + /// cannot hold a connection open behind a decision that never comes. Without a + /// deadline, waits forever. + pub async fn within(&self, work: impl Future) -> crate::Result { + Deadline::bound(self.deadline.as_ref(), async { Ok(work.await) }).await + } + /// Accept the session and return its supervised driver task. /// /// Await the driver before classifying the session close so a panic cannot look like cancellation. From 2425324bbdd58b8c3f912f9a8ca73453b4f12504 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 15:04:45 -0700 Subject: [PATCH 2/4] docs(relay): document the caller-owned admission deadline Add MIGRATE entries for moq-auth and moq-relay, correct the Admissions rustdoc, and note in the CLI guide that --listen-timeout bounds admission. Co-Authored-By: Claude Opus 5.5 --- doc/bin/cli.md | 4 +++- rs/moq-auth/MIGRATE.md | 6 ++++++ rs/moq-relay/MIGRATE.md | 8 ++++++++ rs/moq-relay/src/auth.rs | 12 +++++++----- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/bin/cli.md b/doc/bin/cli.md index 455ebac8acb..3f8b781ed69 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -53,7 +53,9 @@ sessions a reconnect-to-me GOAWAY and waits up to `--drain-timeout` (default such as `moq-lite-03`, get none and are closed when the window ends. A second signal exits immediately; `--drain-timeout 0s` closes sessions immediately. Pending handshakes and admission requests share the same drain window, and an -open stdin pipe does not keep the process alive afterward. +open stdin pipe does not keep the process alive afterward. Admission is part of +the handshake, so `--listen-timeout` bounds it too; `0s` leaves admission without +a deadline. Add `--stats-enabled` before the first stage to publish accepted-session and traffic counters with the relay's `--stats-*` settings. An export-only listener diff --git a/rs/moq-auth/MIGRATE.md b/rs/moq-auth/MIGRATE.md index e915d89025e..e2d2074bd04 100644 --- a/rs/moq-auth/MIGRATE.md +++ b/rs/moq-auth/MIGRATE.md @@ -4,6 +4,12 @@ How to update your code for each breaking change, newest first. ## Unreleased +### `Client::connect` has no timeout of its own (#5765) + +`Client::connect` waits on the auth server for as long as its caller does, and dropping the future drops the request. +A caller without its own deadline, such as a handshake deadline, wraps the call in one, for example `tokio::time::timeout(Duration::from_secs(10), client.connect(request))`. +`attach`, revalidate, and end keep their ten-second bound and still report a stalled server as `Error::Unavailable`. + ### Typed admission refusals (#5996) `Error::Refused` now carries a `Refusal`; construct `Error::Refused(Refusal::default())` for an unattributed refusal and match `Error::Refused(refusal)` to read `reason`, `root`, and `tier`. diff --git a/rs/moq-relay/MIGRATE.md b/rs/moq-relay/MIGRATE.md index 6f6e7637526..0f3c71957c7 100644 --- a/rs/moq-relay/MIGRATE.md +++ b/rs/moq-relay/MIGRATE.md @@ -5,6 +5,14 @@ Rolling a cluster across a release also follows the [upgrade guide](https://moq. ## Unreleased +### Admission runs under the handshake deadline (#5765) + +`listen.timeout` now bounds auth admission as part of the handshake, replacing the fixed ten-second admission timeout, so `"0"` also lets admission wait forever. +HTTP reads bound admission by the web listener's timeout. +`Auth::admit` and `Cluster::admit` no longer time out on their own, so a slow embedded decider no longer refuses after ten seconds: the caller owns the deadline. +Bound them with `moq_tokio::server::Request::within` on an accepted session, or wrap them in `tokio::time::timeout`; dropping the future withdraws the admission from the decider. +Tokens attached in band keep their ten-second bound and are refused as `auth::Error::Unavailable` past it. + ### Usage types come from usage-rs 7 (#6060) The relay's `Args` and `Config` derives now implement usage-rs 7 traits. diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index dec7dac981b..61d611a5c8b 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -980,11 +980,13 @@ fn check_rates(publish: &moq_auth::Access, subscribe: &moq_auth::Access) -> Resu /// The sessions an embedded [`Auth`] is waiting to admit, in arrival order. /// /// The transport has already accepted each one; it waits for its answer, so a -/// slow decider holds connects the way a slow auth server would, and one that -/// takes longer than a server may (ten seconds) is refused as unavailable. An -/// [attached](Admission::attached) token holds one of its session's verification -/// slots until the decider answers or drops it, even past that, and the session's -/// later tokens wait for a slot before they reach the decider. +/// slow decider holds connects the way a slow auth server would. A connection's +/// admission has no bound of its own: whoever awaits [`Auth::admit`] owns the +/// deadline, which the relay's listeners set to their handshake deadline. An +/// [attached](Admission::attached) token is refused as unavailable after ten +/// seconds, but holds one of its session's verification slots until the decider +/// answers or drops it, even past that, and the session's later tokens wait for a +/// slot before they reach the decider. /// Answer in place or hand each [`Admission`] to its own task; nothing here /// serializes them. pub struct Admissions(mpsc::UnboundedReceiver); From 69aa5f4c48fc24d4eec766c479cc05bfd7e1dcf1 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 15:34:35 -0700 Subject: [PATCH 3/4] docs(cli): migrate --listen-timeout and document Web admission timeout Add a moq-cli MIGRATE entry for admission moving under --listen-timeout, name the CLI flag in its changelog, and include HTTP admission in the Web::with_timeout rustdoc. Co-Authored-By: Claude Opus 5.5 --- rs/moq-cli/CHANGELOG.md | 2 +- rs/moq-cli/MIGRATE.md | 5 +++++ rs/moq-relay/src/web.rs | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rs/moq-cli/CHANGELOG.md b/rs/moq-cli/CHANGELOG.md index 460d255a616..6fa912bb60f 100644 --- a/rs/moq-cli/CHANGELOG.md +++ b/rs/moq-cli/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- `moq --listen` bounds auth admission by the listener's `listen.timeout` handshake deadline instead of a fixed ten seconds. +- `moq --listen` bounds auth admission by the listener's `--listen-timeout` handshake deadline instead of a fixed ten seconds. ## [0.14.2](https://github.com/moq-dev/moq/compare/moq-cli-v0.14.1...moq-cli-v0.14.2) - 2026-10-06 diff --git a/rs/moq-cli/MIGRATE.md b/rs/moq-cli/MIGRATE.md index 3e697d3d0fe..0bf4c27bb0f 100644 --- a/rs/moq-cli/MIGRATE.md +++ b/rs/moq-cli/MIGRATE.md @@ -4,6 +4,11 @@ How to update your invocation and config for each breaking change, newest first. ## Unreleased +### `--listen-timeout` bounds admission (#5765) + +`moq --listen` now finishes auth admission within the `--listen-timeout` handshake deadline (default `10s`, counted from the first packet) instead of a separate fixed ten seconds, so a short timeout now refuses a slow auth server sooner and `0s` waits on it forever. +If your auth server can take longer than the handshake timeout allows, raise `--listen-timeout`. + ### `--epoch` is removed (#5967) Remove `--epoch` and `MOQ_EPOCH`: `--epoch` is now an unknown flag, and `MOQ_EPOCH` is ignored. diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index 2a50ee92b3c..1c057b99be1 100644 --- a/rs/moq-relay/src/web.rs +++ b/rs/moq-relay/src/web.rs @@ -337,8 +337,9 @@ impl Web { /// Close a connection that sits this long with no complete request in flight, /// including one stalled in its TLS handshake or headers or idle in keep-alive, - /// and bound a WebSocket's MoQ SETUP after the upgrade; `None`, or a timeout past the - /// clock's range, waits forever. Defaults to the + /// bound an HTTP request's auth admission (answering 502 past it), and bound a + /// WebSocket's MoQ SETUP after the upgrade; `None`, or a timeout past the clock's + /// range, waits forever. Defaults to the /// [`moq_tokio::listen::Config::resolved_timeout`] default. pub fn with_timeout(mut self, timeout: Option) -> Self { let state = Arc::get_mut(&mut self.state).expect("with_timeout called after routes were built"); From 47f105581dcd1a320214dd3d02d5c44a36322a84 Mon Sep 17 00:00:00 2001 From: Melanie Riise Date: Tue, 20 Oct 2026 19:10:08 -0700 Subject: [PATCH 4/4] docs(relay): scope admission withdrawal to the server decider Co-Authored-By: Claude Opus 5.5 --- rs/moq-relay/MIGRATE.md | 2 +- rs/moq-relay/src/auth.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rs/moq-relay/MIGRATE.md b/rs/moq-relay/MIGRATE.md index 0f3c71957c7..7abb9a054f2 100644 --- a/rs/moq-relay/MIGRATE.md +++ b/rs/moq-relay/MIGRATE.md @@ -10,7 +10,7 @@ Rolling a cluster across a release also follows the [upgrade guide](https://moq. `listen.timeout` now bounds auth admission as part of the handshake, replacing the fixed ten-second admission timeout, so `"0"` also lets admission wait forever. HTTP reads bound admission by the web listener's timeout. `Auth::admit` and `Cluster::admit` no longer time out on their own, so a slow embedded decider no longer refuses after ten seconds: the caller owns the deadline. -Bound them with `moq_tokio::server::Request::within` on an accepted session, or wrap them in `tokio::time::timeout`; dropping the future withdraws the admission from the decider. +Bound them with `moq_tokio::server::Request::within` on an accepted session, or wrap them in `tokio::time::timeout`; dropping the future drops the auth server's in-flight request, but an embedded decider is not told and should bound its own work. Tokens attached in band keep their ten-second bound and are refused as `auth::Error::Unavailable` past it. ### Usage types come from usage-rs 7 (#6060) diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index 61d611a5c8b..74455dddbdf 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -899,8 +899,8 @@ impl Auth { /// /// Waits on the decider for as long as the caller does. The caller owns the /// deadline: a listener bounds it with the connection's handshake deadline - /// ([`moq_tokio::server::Request::within`]), and dropping the future withdraws - /// the admission from the decider. + /// ([`moq_tokio::server::Request::within`]). Dropping the future drops a server + /// decider's in-flight request; an embedder's [`Admission`] is not told. pub async fn admit(&self, request: Request) -> Result { // Build the token from the grant the admission checked: re-reading it could // pick up an update that skipped the check.