Skip to content

Allow sendmmsg to carry an extra payload added to every msg - #2580

Open
nmldiegues wants to merge 1 commit into
cloudflare:masterfrom
nmldiegues:nuno/flexible-sendmmsg
Open

Allow sendmmsg to carry an extra payload added to every msg#2580
nmldiegues wants to merge 1 commit into
cloudflare:masterfrom
nmldiegues:nuno/flexible-sendmmsg

Conversation

@nmldiegues

Copy link
Copy Markdown

Add sendmmsg_with_suffix, a variant of sendmmsg that appends a
caller-supplied suffix (e.g. shared framing) to every datagram in the
batch using an extra iovec per message, avoiding a copy into a
combined buffer.

Fix two latent bugs in sendmmsg along the way:

  • A partial batch failure after some messages had already been sent
    would discard the last OS error and silently report success.
  • The early-exit-on-short-write check compared against MAX_MMSG
    instead of the current chunk's length, so the last (possibly
    shorter) chunk never triggered early exit.
  • Zero-length input now returns Ok(0) instead of hitting msgvec
    with no capacity.

iovecs is fully populated before any mmsghdr.msg_iov pointers are
taken, per the safety invariant documented in mmsg.rs/AGENTS.md,
preventing dangling pointers from a SmallVec reallocation.

Renames the sendmmsg test to send_many and adds coverage for the
new suffix path, empty batches, and error propagation without
progress.

@nmldiegues
nmldiegues requested a review from a team as a code owner August 12, 2026 10:02
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.

1 participant