refactor(uring)!: derive worker and steering identity from the socket - #3865
Conversation
`Endpoint::new` took a Handle next to a socket that already named its worker, and `endpoint::Config::shard` was settable independently of the socket's slot in the reuseport group. Both are now derived: `Handle::udp` adopts a lone socket or a completed `moq_sock::shard::Socket` member, the socket carries its worker (weakly) and shard, and the endpoint, its connections, and the WebTransport handshake run on that worker. An endpoint on a dropped worker is refused up front, and a dial or accept on one that outlived its worker fails instead of parking forever. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The client's handshake completes before the server's, so a client that stopped after connecting never sent its last flight and the owner's accept waited on a handshake that had timed out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 4 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (25)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
Fixed in c1de2ce: the README's steering bullet now describes adopting the member through (Written by Claude Opus 5) |
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No issues found. |
|
No issues found. |
|
No issues found. |




Problem
moq_uring::quic::Endpoint::newtook aHandlenext to audp::SocketthatHandle::udphad already tied to a worker, andendpoint::Config::shardwas settable independently of the socket's slot in itsSO_REUSEPORTgroup. A socket from worker A combined with handle B split receive I/O and driver progress across unrelated loops; a wrong shard steered replies to another member's socket.web::Request::acceptrepeated the handle beside a connection that already had an owner. None of these mismatches were refused.Completes uring identity.
Approach
Handle::udpadoptsimpl Into<udp::Bound>: a loneUdpSocket, or a completedmoq_sock::shard::Socketmember, which is the only way a socket gets a steering slot.Endpoint::new(socket, config)derives the worker and the shard from the socket. Its demux, every connection driver, and the WebTransport capsule reader and close timers run on that worker.web::Request::accept(conn)takes the worker from the connection.worker::Owner(aWeak<Shared>plus the timer heap) replaces the strongHandlethe endpoint, connections, and web session used to hold, so an I/O handle cannot keep a dropped worker's ring alive.Handle::udpwhole. moq-tokio already threads the completed member into its server, so its plumbing and published surface are untouched.Impact
Breaking, all in unpublished
moq-uring0.0.1 (moq-sock and the wire are unchanged):Handle::udp(socket: impl Into<udp::Bound>, config)replacesHandle::udp(UdpSocket, config). ExistingUdpSocketcallers compile as before.udp::Bound { Lone(UdpSocket), Member(moq_sock::shard::Socket) }withFromfor both.quic::Endpoint::new(socket, config)drops the&Handleparameter.quic::endpoint::Configlosesshardandwith_shard.quic::client::connect(socket, config)andquic::server::accept(socket, config)drop the&Handleparameter.quic::web::Request::accept(conn)drops the&Handleparameter.Endpoint::new,Endpoint::connect, andEndpoint::acceptreportquic::Error::Ioonce the socket's worker is gone.Wire: no format change.
Validation
rs/moq-uring/tests/identity.rs: an endpoint on a stopped worker is refused; a dial and an accept on an endpoint that outlived its worker fail at once; two workers on one thread, where the endpoint only progresses once the worker that adopted its socket runs.tests/workers.rs(two-member steered listener) now adopts the member whole;tests/web.rscovers WebTransport setup through the connection-owned worker.cargo-zigbuild clippy --target x86_64-unknown-linux-gnu -p moq-uring -p moq-relay --features moq-relay/io-uring,moq-relay/qlog --all-targets -- -D warnings, plus rustdoc with-D warnings. The new tests ran green in a privileged Linux 6.19 podman container, and the two-worker test was mutation-checked (driving the owner in the stall phase fails it). The moq-uring tests run for real in the LinuxTestjob.just check,just test,quest check.Drive-by:
rs/moq-relay/tests/runtime_uring.rshad an unusedmutthat failed the nightlyrs uringrecipe's clippy pass, so that job could not compile this change; removed.Alternatives
Config::shardand documenting that it must match the member: rejected by the quest; a value the caller has to remember is the mismatch this fixes.Handleinside the endpoint (the previous shape, just derived): simpler, but an endpoint or connection outliving its worker would then keep the ring open.udpand a member-specific one) instead ofInto<udp::Bound>: more surface for the same rule.Follow-ups
rs uringjob has never passed since it was added (compile errors on main that fix(relay): match the uring driver's terminal error #3860 and this PR fix); worth watching the next run.🤖 Generated with Claude Code