Skip to content

tokio-quiche: drain coalesced QUIC packets on recv#2443

Closed
babasha wants to merge 2 commits into
cloudflare:masterfrom
babasha:fix/coalesced-recv-v0.12
Closed

tokio-quiche: drain coalesced QUIC packets on recv#2443
babasha wants to merge 2 commits into
cloudflare:masterfrom
babasha:fix/coalesced-recv-v0.12

Conversation

@babasha
Copy link
Copy Markdown

@babasha babasha commented Apr 20, 2026

quiche::Connection::recv only processes one QUIC packet per call, but a single UDP datagram can contain several coalesced packets (a server commonly coalesces Initial + Handshake, and loopback MTU=65536 makes this common in local tests). The existing call sites in ClientConnector and IoWorker invoked recv once per buffer, so any packet coalesced after the first was silently discarded -- handshakes stall waiting for a Handshake-level frame that was already delivered.

Introduce a recv_coalesced helper at each call site that loops over conn.recv until it returns Done, advancing the buffer by the number of bytes quiche consumed.

quiche::Connection::recv only processes one QUIC packet per call, but a
single UDP datagram can contain several coalesced packets (a server
commonly coalesces Initial + Handshake, and loopback MTU=65536 makes
this common in local tests). The existing call sites in ClientConnector
and IoWorker invoked recv once per buffer, so any packet coalesced after
the first was silently discarded -- handshakes stall waiting for a
Handshake-level frame that was already delivered.

Introduce a recv_coalesced helper at each call site that loops over
conn.recv until it returns Done, advancing the buffer by the number of
bytes quiche consumed.
@babasha babasha requested a review from a team as a code owner April 20, 2026 22:38
Record debug information when recv_coalesced encounters an error. Previously the code silently broke on any Err; now it logs the error and the source (recv_info.from) before breaking to aid debugging of client connector receive failures.
@LPardue
Copy link
Copy Markdown
Contributor

LPardue commented Apr 21, 2026

quiche's recv() handles coalesced packets, as noted in https://github.com/cloudflare/quiche/blob/master/quiche/src/lib.rs#L2819. Therefore, I don't understand what problem is being addressed

@antoniovicente
Copy link
Copy Markdown
Contributor

antoniovicente commented Apr 23, 2026

quiche's recv() handles coalesced packets, as noted in https://github.com/cloudflare/quiche/blob/master/quiche/src/lib.rs#L2819. Therefore, I don't understand what problem is being addressed

Some evidence of it being handled correctly: If you look at the recv() implementation, you'll notice that the 2 cases that return Ok() should return a number of bytes equal to buf.len() since done should equal len when left == 0

@babasha babasha closed this May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants