diff --git a/Cargo.lock b/Cargo.lock index 9b836429c59..1c1044e7485 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4796,6 +4796,7 @@ dependencies = [ "tracing", "url", "usage-rs", + "web-transport-moq", "web-transport-trait", ] diff --git a/doc/bin/relay/config.md b/doc/bin/relay/config.md index ee7a24c5956..6fd3e0a1b9f 100644 --- a/doc/bin/relay/config.md +++ b/doc/bin/relay/config.md @@ -41,7 +41,6 @@ solicit = false # Decline MoQ Solicit, so peers may announc `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. -The `io_uring` workers do not apply it. 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 38a87c57bec..1728bc4b21f 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -168,7 +168,6 @@ disabled rung strands WHEP, HLS, and moq-mux export viewers. - [Plan: watch worker](/quest/m1/plan-watch-worker.md) - prototype an invisible page worker against app-spawned workers, and land the jank harness that decides - [Watch worker](/quest/m1/watch-worker.md) - watch playback runs in a worker onto an OffscreenCanvas, so main-thread jank never stalls video or audio - [Front deadlines](/quest/m1/front-deadline-index.md) - a front's per-event cost stops growing with its track count: an expiry index and per-track wakes, proven by a churn benchmark -- [io_uring handshake deadline](/quest/m1/listener-deadlines.md) - the io_uring workers apply `listen.timeout` to the handshake - [Rust papercuts](/quest/m1/papercuts-rs.md) - HTTP refusals are counted, and a `u64::MAX` resume is unbounded - [Duration parser defaults](/quest/m1/cli-duration-defaults.md) - a moq-tokio duration set in code beats the parser default on a parsed or merged config, zero included, after #5350 - [Front parking](/quest/m1/origin-front-parks.md) - an unroutable request waits on a front instead of re-asking on every route-table move diff --git a/quest/m1/listener-deadlines.md b/quest/m1/listener-deadlines.md deleted file mode 100644 index ffc79ca0ab3..00000000000 --- a/quest/m1/listener-deadlines.md +++ /dev/null @@ -1,34 +0,0 @@ -# [S] io_uring workers bound the handshake - -## Goal - -The io_uring workers bound a slow handshake the way the default runtime does -after the handshake deadline (moq-dev/moq#4612), by applying -`listen.timeout`. - -## Plan - -- `rs/moq-relay/src/uring.rs` `serve_connection`: bound the - WebTransport `Request::accept`, `respond`, and `accept_request_lite` by one - deadline from `listen::Config::resolved_timeout()`, on the worker's own - timer (`rs/moq-uring/src/timer.rs`), closing with the timeout code. Delete - the "There is no timeout here" note in `rs/moq-uring/src/quic/web.rs`, and - the matching caveat in `doc/bin/relay/config.md`. -- Test on the worker's timer: a stalled handshake closes at the deadline. - Decided 2026-10-10 from review: this waits for - [moq-uring on moq-time](/quest/m1/time/uring.md), so the test runs on - controlled time instead of the private timer heap. - -Split on 2026-10-08: the HTTP/2 idle deadline is -[HTTP listener deadlines](https://github.com/moq-dev/moq/pull/5245). The iroh -keep-alive landed on its own. - -Public API: none beyond existing settings. Wire: none. - -## Required - -- [moq-uring on moq-time](/quest/m1/time/uring.md) - the worker's timer becomes a moq-time backend, so the deadline tests on controlled time - -## Related - -- [HTTP listener deadlines](https://github.com/moq-dev/moq/pull/5245) - the HTTPS and internal listeners' half diff --git a/quest/m1/time/uring.md b/quest/m1/time/uring.md index 67b32c3466d..0a2a0508cfc 100644 --- a/quest/m1/time/uring.md +++ b/quest/m1/time/uring.md @@ -25,6 +25,10 @@ flavors, and relay CPU via `just bench BASE` on Linux. The existing keep-alive and idle-timeout tests stay unchanged. Ban direct clock reads in moq-uring outside its backend (the ratchet). +Move `uring_workers_bound_stalled_handshakes` (`rs/moq-relay/tests/runtime_uring.rs`) +onto controlled time too; it landed on the wall clock in #5244 rather than +waiting for this quest. + Public API: breaking. `moq_uring::Timer` is re-exported, and `Timer::set` takes `Option` instead of std's; no conversion shim. Wire: none. diff --git a/quest/m2/relay-io-uring-package.md b/quest/m2/relay-io-uring-package.md index ae5b666f90a..21b7a153d7d 100644 --- a/quest/m2/relay-io-uring-package.md +++ b/quest/m2/relay-io-uring-package.md @@ -37,5 +37,4 @@ Public API: none. Wire: none. - [moq-transport on io_uring](/quest/m2/uring-ietf.md) - a packaged relay must not drop protocols when the ring is on - [Dropped session close](/quest/m2/uring-drop-close.md) - closes are delivered when a session is dropped on the ring -- [Listener deadlines](/quest/m1/listener-deadlines.md) - the io_uring workers apply `listen.timeout` like the default runtime - [One port on the io_uring workers](/quest/m2/uring-demux.md) - a one-port config is served on the ring too diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index 602d70ae1aa..70a2f50f76e 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -99,6 +99,7 @@ rand = { workspace = true } rcgen = "0.14" tempfile = { workspace = true } tokio = { workspace = true, features = ["test-util"] } +web-transport-moq = { workspace = true } # Which sockets the process still holds, so the embed tests can prove a stopped # relay closed its own without rebinding a port another test could take. diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index 70bd2012195..7fbbdd38fd9 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -70,6 +70,9 @@ struct Serve { versions: moq_net::Versions, /// The address every worker socket shares, reported as a session's `local`. local: SocketAddr, + /// `listen.timeout`, which each worker's endpoint starts at a connection's + /// first packet. + timeout: Option, } /// A bound group of io_uring QUIC workers sharing one port. @@ -94,6 +97,7 @@ pub struct Workers { pin: bool, alpns: Arc>, versions: moq_net::Versions, + timeout: Option, threads: Vec<(u16, std::thread::JoinHandle<()>)>, stops: Vec>, @@ -249,6 +253,7 @@ impl Workers { pin: config.pin, alpns: Arc::new(alpns), versions, + timeout: listen.resolved_timeout(), threads: Vec::new(), stops: Vec::new(), failures, @@ -300,6 +305,7 @@ impl Workers { alpns: self.alpns.clone(), versions: self.versions.clone(), local: self.addr, + timeout: self.timeout, }; let cores = match self.pin { @@ -537,6 +543,7 @@ fn serve_worker(spawn: Spawn) -> bool { .context("failed to adopt the worker socket")?; let mut endpoint_config = moq_uring::quic::endpoint::Config::default().with_server(server); endpoint_config.activity = serve.shutdown.activity.clone(); + endpoint_config.handshake.timeout = serve.timeout; let endpoint = moq_uring::quic::Endpoint::new(socket, endpoint_config).context("failed to build the QUIC endpoint")?; Ok((worker, endpoint)) @@ -583,6 +590,45 @@ fn serve_worker(spawn: Spawn) -> bool { true } +/// What remains of a connection's handshake deadline, and how to tell the peer +/// it passed. +struct Deadline { + timer: moq_uring::Timer, + /// Closes with the timeout code once a session exists to carry it. Until + /// then a timed-out handshake is just dropped, and its guard closes in the + /// handshake's own error space, as HTTP/3 has no MoQ codes. + close: Option, +} + +impl Deadline { + fn new(handle: &moq_uring::Handle, conn: &moq_uring::quic::Connection) -> Self { + let mut timer = handle.timer(); + timer.set(conn.handshake().deadline); + Self { timer, close: None } + } + + async fn bound>( + &mut self, + handshake: impl Future>, + ) -> anyhow::Result { + use web_transport_trait::poll::Session as _; + let timer = std::pin::pin!(self.timer.wait()); + let handshake = std::pin::pin!(handshake); + match futures::future::select(timer, handshake).await { + futures::future::Either::Left(_) => { + // Close before dropping the pending handshake, whose cancellation guard + // would otherwise replace the timeout with an abandoned-handshake error. + let err = moq_net::Error::Timeout; + if let Some(close) = &mut self.close { + close.close(moq_net::SessionError::Timeout.to_code(), &err.to_string()); + } + Err(err.into()) + } + futures::future::Either::Right((result, _)) => result.map_err(Into::into), + } + } +} + /// Serve one accepted connection on its worker: handshake and session start /// here; authentication and supervision on the shared runtime. async fn serve_connection( @@ -593,6 +639,10 @@ async fn serve_connection( ) -> anyhow::Result<()> { use web_transport_trait::poll::Session as _; + // The endpoint started this deadline at the connection's first packet and + // enforced it through the QUIC handshake; it covers SETUP OK too. + let mut deadline = Deadline::new(&handle, &conn); + // Read the link facts now: the handshake below consumes the connection. let remote = conn.remote_addr(); let sni = conn.server_name().map(str::to_owned); @@ -617,7 +667,8 @@ async fn serve_connection( let mut alpn = conn.protocol().map(str::to_owned); let (transport, url) = match conn.protocol() { Some("h3") => { - let request = moq_uring::quic::web::Request::accept(conn) + let request = deadline + .bound(moq_uring::quic::web::Request::accept(conn)) .await .context("WebTransport handshake failed")?; let url = request.url().clone(); @@ -631,8 +682,8 @@ async fn serve_connection( response = response.with_protocol(protocol); } alpn = protocol.clone(); - let session = request - .respond(response) + let session = deadline + .bound(request.respond(response)) .await .context("WebTransport response failed")?; (session, Some(url)) @@ -640,9 +691,10 @@ async fn serve_connection( _ => (moq_uring::quic::web::Session::raw(conn), None), }; - let request = moq_net::Server::new() - .with_versions(serve.versions.clone()) - .accept_request_lite(std::time::Instant::now(), moq_uring::transport::Session::new(transport)) + deadline.close = Some(transport.clone()); + let server = moq_net::Server::new().with_versions(serve.versions.clone()); + let request = deadline + .bound(server.accept_request_lite(std::time::Instant::now(), moq_uring::transport::Session::new(transport))) .await .context("moq handshake failed")?; @@ -766,7 +818,7 @@ async fn serve_connection( request = request.with_subscriber(publisher); } let lease = lease.preparing(request.auth(), request.role())?; - let (session, driver) = request.ok().await?; + let (session, driver) = deadline.bound(request.ok()).await?; let driver_handle = handle.clone(); handle.spawn(async move { match driver_handle.run(driver).await { diff --git a/rs/moq-relay/tests/runtime_uring.rs b/rs/moq-relay/tests/runtime_uring.rs index 363ee4650b6..c542abbf1c1 100644 --- a/rs/moq-relay/tests/runtime_uring.rs +++ b/rs/moq-relay/tests/runtime_uring.rs @@ -759,3 +759,117 @@ async fn uring_auth_reports_distinct_quic_and_webtransport() { running.abort(); let _ = running.await; } + +/// `listen.timeout` bounds every handshake phase from the first packet: TLS, +/// HTTP/3 before CONNECT, and MoQ SETUP over raw QUIC and WebTransport. Each +/// phase closes in its own error space. +#[cfg(feature = "noq")] +#[tokio::test] +async fn uring_workers_bound_stalled_handshakes() { + use web_transport_moq::noq; + use web_transport_trait::Error as _; + + let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); + if !supported() { + return; + } + let dir = tempfile::tempdir().expect("tempdir"); + let (cert, key) = certificate(dir.path()); + let mut config = uring_config(&cert, &key); + config.listen.timeout = Duration::from_millis(200); + let relay = Relay::load(config).await.expect("load relay"); + let port = relay.addr().expect("workers bound an address").port(); + let addr = SocketAddr::from(([127, 0, 0, 1], port)); + let running = tokio::spawn(relay.run()); + + let mut config = moq_tokio::connect::Config::default(); + config.tls.insecure = Some(true); + let tls = config.tls.build().expect("tls config"); + let crypto = |alpn: &[u8]| { + let mut tls = tls.clone(); + tls.alpn_protocols = vec![alpn.to_vec()]; + let crypto = noq::crypto::rustls::QuicClientConfig::try_from(tls).expect("QUIC crypto"); + noq::ClientConfig::new(std::sync::Arc::new(crypto)) + }; + let client = noq::Endpoint::client("127.0.0.1:0".parse().unwrap()).expect("client"); + + // TLS: the relay never hears more than the ClientHello, so only its own + // deadline can end the handshake before the idle timeout does. + let hop = stall_after_hello(addr).await; + let stalled = client.connect_with(crypto(b"moq-lite-06"), hop, "localhost").unwrap(); + let error = tokio::time::timeout(TIMEOUT, async { + match stalled.await { + Ok(conn) => conn.closed().await, + Err(err) => err, + } + }) + .await + .expect("listener did not bound the QUIC handshake"); + assert!( + !matches!(error, noq::ConnectionError::TimedOut), + "the relay must close a stalled QUIC handshake: {error}" + ); + + // `h3` stalls before CONNECT, where only HTTP/3 codes apply. + const H3_GENERAL_PROTOCOL_ERROR: u32 = 0x0101; + let timeout = moq_net::SessionError::Timeout.to_code(); + for (scheme, code) in [("moql", timeout), ("https", timeout), ("h3", H3_GENERAL_PROTOCOL_ERROR)] { + let session = tokio::time::timeout(TIMEOUT, async { + let alpn: &[u8] = if scheme == "moql" { b"moq-lite-06" } else { b"h3" }; + let conn = client + .connect_with(crypto(alpn), addr, "localhost") + .unwrap() + .await + .unwrap(); + if scheme == "https" { + let url: url::Url = format!("https://{addr}/stalled").parse().unwrap(); + let request = + web_transport_moq::proto::ConnectRequest::new(url).with_protocol("moq-lite-06".to_string()); + web_transport_moq::Session::connect(conn, request).await.unwrap() + } else { + web_transport_moq::Session::raw(conn) + } + }) + .await + .expect("transport handshake timeout"); + let error = tokio::time::timeout(TIMEOUT, session.closed()) + .await + .expect("listener did not enforce its handshake deadline"); + // The WebTransport wrapper translates its close code back to the MoQ value. + assert_eq!( + error.session_error().map(|(code, _)| code), + Some(code), + "{scheme}: {error}" + ); + } + client.close(noq::VarInt::from_u32(0), b"test complete"); + client.wait_idle().await; + running.abort(); + let _ = running.await; +} + +/// A UDP hop to `server` that forwards one client's datagrams until the server +/// first answers, and every answer back, so the server never sees the client +/// finish its handshake. Returns the address to dial. +#[cfg(feature = "noq")] +async fn stall_after_hello(server: SocketAddr) -> SocketAddr { + let socket = tokio::net::UdpSocket::bind("127.0.0.1:0").await.expect("bind hop"); + let addr = socket.local_addr().expect("hop address"); + tokio::spawn(async move { + let mut client = None; + let mut answered = false; + let mut buf = vec![0; usize::from(u16::MAX)]; + while let Ok((len, from)) = socket.recv_from(&mut buf).await { + if from == server { + answered = true; + if let Some(client) = client { + let _ = socket.send_to(&buf[..len], client).await; + } + } else if !answered { + client = Some(from); + let _ = socket.send_to(&buf[..len], server).await; + } + } + }); + addr +} diff --git a/rs/moq-uring/src/quic/endpoint.rs b/rs/moq-uring/src/quic/endpoint.rs index 47e38d3caaf..a21d8214256 100644 --- a/rs/moq-uring/src/quic/endpoint.rs +++ b/rs/moq-uring/src/quic/endpoint.rs @@ -49,6 +49,9 @@ pub struct Config { /// peer retransmits and lands once the application drains the backlog or /// a handshake fails. pub backlog: usize, + + /// How incoming handshakes are bounded. + pub handshake: super::handshake::Config, } impl Default for Config { @@ -57,6 +60,7 @@ impl Default for Config { server: None, activity: Default::default(), backlog: 1024, + handshake: Default::default(), } } } diff --git a/rs/moq-uring/src/quic/handshake.rs b/rs/moq-uring/src/quic/handshake.rs new file mode 100644 index 00000000000..8b09b8b0a4c --- /dev/null +++ b/rs/moq-uring/src/quic/handshake.rs @@ -0,0 +1,29 @@ +//! The handshake an accepted connection goes through before it is served. +//! +//! An [`Endpoint`](super::Endpoint) bounds it by [`Config::timeout`] from the +//! connection's first packet, closing a QUIC handshake still running at the +//! deadline. The rest of the deadline is handed to whatever the application +//! layers on top (HTTP/3, MoQ SETUP) as [`Info::deadline`]. + +use std::time::{Duration, Instant}; + +/// How an endpoint bounds the handshakes it accepts. +#[derive(Clone, Debug, Default)] +#[non_exhaustive] +pub struct Config { + /// How long an incoming connection has from its first packet to finish its + /// whole handshake, or `None` (the default) for no bound but the idle + /// timeout. + pub timeout: Option, +} + +/// An established connection's handshake, from +/// [`Connection::handshake`](super::Connection::handshake). +#[derive(Clone, Copy, Debug)] +#[non_exhaustive] +pub struct Info { + /// When the handshake, including whatever the application layers on top of + /// QUIC, must be done. `None` on a dialed connection or without a + /// [`Config::timeout`]. + pub deadline: Option, +} diff --git a/rs/moq-uring/src/quic/mod.rs b/rs/moq-uring/src/quic/mod.rs index 95989b906c5..ab8e13f0842 100644 --- a/rs/moq-uring/src/quic/mod.rs +++ b/rs/moq-uring/src/quic/mod.rs @@ -21,6 +21,7 @@ pub mod client; pub mod endpoint; +pub mod handshake; #[cfg(feature = "qlog")] pub mod qlog; pub mod server; diff --git a/rs/moq-uring/src/quic/noq/connection.rs b/rs/moq-uring/src/quic/noq/connection.rs index 87e56d64b47..9def53c5ee1 100644 --- a/rs/moq-uring/src/quic/noq/connection.rs +++ b/rs/moq-uring/src/quic/noq/connection.rs @@ -285,6 +285,7 @@ pub struct Connection { server_name: Option, /// The peer's address when the handshake completed. remote: SocketAddr, + handshake: crate::quic::handshake::Info, } impl Connection { @@ -330,6 +331,12 @@ impl Connection { pub fn server_name(&self) -> Option<&str> { self.server_name.as_deref() } + + /// The handshake this connection went through, and when all of it must be + /// done. + pub fn handshake(&self) -> &crate::quic::handshake::Info { + &self.handshake + } } impl Clone for Connection { @@ -340,6 +347,7 @@ impl Clone for Connection { alpn: self.alpn.clone(), server_name: self.server_name.clone(), remote: self.remote, + handshake: self.handshake, } } } @@ -392,14 +400,29 @@ impl Drop for EstablishGuard { } } -/// Wait out the handshake, yielding the connection's public handle. -pub(crate) async fn establish(shared: Shared) -> Result { +/// Wait out the handshake, yielding the connection's public handle, or close +/// the connection if it is still handshaking at `deadline`. +pub(crate) async fn establish(shared: Shared, deadline: Option) -> Result { let mut guard = EstablishGuard { shared: Some(shared.clone()), }; + let mut timer = deadline.map(|at| { + let mut timer = shared.owner.timer(); + timer.set(Some(at)); + timer + }); + let mut expired = false; let result = kio::wait(|waiter| { + // The deadline goes first, so a handshake that completed in the same + // turn it expired is still refused. The close resolves this wait once + // the driver has staged it. + if timer.as_mut().is_some_and(|timer| timer.poll(waiter).is_ready()) { + timer = None; + expired = true; + shared.close_code(0, "QUIC handshake timed out"); + } let mut state = shared.state.borrow_mut(); - if state.established { + if state.established && !expired { return Poll::Ready(Ok(())); } if let Some(err) = &state.closed { @@ -442,6 +465,7 @@ pub(crate) async fn establish(shared: Shared) -> Result { alpn, server_name, remote, + handshake: crate::quic::handshake::Info { deadline }, }; guard.shared = None; Ok(conn) diff --git a/rs/moq-uring/src/quic/noq/endpoint.rs b/rs/moq-uring/src/quic/noq/endpoint.rs index e66adc709ad..2a7ff9d8e5d 100644 --- a/rs/moq-uring/src/quic/noq/endpoint.rs +++ b/rs/moq-uring/src/quic/noq/endpoint.rs @@ -54,6 +54,7 @@ pub(crate) struct Inner { /// bounded by [`Config::backlog`]. pending: Cell, backlog: usize, + handshake: crate::quic::handshake::Config, /// Live [`Endpoint`] handles; at zero the endpoint winds down (no new /// accepts or dials, existing connections served until they end). handles: Cell, @@ -112,6 +113,7 @@ impl Endpoint { conns: RefCell::new(FxHashMap::default()), pending: Cell::new(0), backlog: config.backlog, + handshake: config.handshake, handles: Cell::new(1), closed: RefCell::new(None), task_waiters: RefCell::new(kio::WaiterList::new()), @@ -168,7 +170,7 @@ impl Endpoint { let shared = self.inner.launch(key, conn); // Flush the Initial flight; the demux task takes it from here. shared.kick(); - connection::establish(shared).await + connection::establish(shared, None).await } } @@ -337,7 +339,9 @@ impl Inner { return None; }; buf.clear(); - let accepted = self.endpoint.borrow_mut().accept(incoming, Instant::now(), buf, None); + let now = Instant::now(); + let deadline = self.handshake.timeout.and_then(|timeout| now.checked_add(timeout)); + let accepted = self.endpoint.borrow_mut().accept(incoming, now, buf, None); let (key, conn) = match accepted { Ok(accepted) => accepted, Err(err) => { @@ -356,7 +360,7 @@ impl Inner { self.pending.set(self.pending.get() + 1); let inner = self.clone(); self.owner.spawn(async move { - let outcome = connection::establish(shared).await; + let outcome = connection::establish(shared, deadline).await; inner.pending.set(inner.pending.get() - 1); let mut conn = match outcome { Ok(conn) => conn, diff --git a/rs/moq-uring/src/quic/web.rs b/rs/moq-uring/src/quic/web.rs index 2a8537a8708..915724d1950 100644 --- a/rs/moq-uring/src/quic/web.rs +++ b/rs/moq-uring/src/quic/web.rs @@ -133,21 +133,26 @@ impl Request { /// take the CONNECT request. /// /// Everything the session later spawns runs on the worker already driving - /// `conn`. There is no timeout here; a peer that stalls mid-handshake is - /// bounded by the connection's idle timeout. - pub async fn accept(conn: Connection) -> Result { + /// `conn`. No deadline here: a caller bounding the handshake, say by + /// [`Info::deadline`](super::handshake::Info::deadline), drops this + /// future, which closes the connection with an HTTP/3 error, even if it + /// was never polled. + pub fn accept(conn: Connection) -> impl Future> { // The endpoint and driver retain this connection after the future is - // dropped. Own its close before the first await; the returned Request - // takes over that duty once the handshake succeeds. + // dropped. Own its close before returning, not at the first poll, so a + // deadline that has already passed cannot drop the future unguarded. + // The returned Request takes over that duty once the handshake succeeds. let mut guard = Guard::new(conn.clone()); - match Self::handshake(conn).await { - Ok(request) => { - guard.disarm(); - Ok(request) - } - Err(err) => { - guard.close(&err.to_string()); - Err(err) + async move { + match Self::handshake(conn).await { + Ok(request) => { + guard.disarm(); + Ok(request) + } + Err(err) => { + guard.close(&err.to_string()); + Err(err) + } } } } diff --git a/rs/moq-uring/tests/web.rs b/rs/moq-uring/tests/web.rs index faa0c762d91..59988ab70c1 100644 --- a/rs/moq-uring/tests/web.rs +++ b/rs/moq-uring/tests/web.rs @@ -401,6 +401,35 @@ fn an_abandoned_handshake_closes_the_connection() { client.join().expect("client thread"); } +/// A handshake dropped before its first poll, as when its deadline has already +/// passed, still closes the connection. +#[test] +fn an_unpolled_handshake_closes_the_connection() { + let Some(mut worker) = worker() else { return }; + let handle = worker.handle(); + let certs = support::certs().expect("certificates"); + let endpoint = h3_endpoint(&handle, &certs); + let addr = endpoint.local_addr(); + + let client = noq_client_err(format!("https://{addr}/")); + + worker + .block_on(async move { + let conn = endpoint.accept().await.expect("accept"); + let mut watch = conn.clone(); + drop(quic::web::Request::accept(conn)); + within( + &handle, + "the unpolled handshake's connection to close", + std::future::poll_fn(|cx| watch.poll_closed(cx)), + ) + .await; + }) + .expect("worker"); + + client.join().expect("client thread"); +} + /// A rejection reaches the peer as the status it was sent. /// /// The HTTP/3 critical streams (the peer's control and QPACK streams, and