Repository navigation
Conversation
ArniDagur
marked this pull request as draft
December 3, 2026 04:16
ArniDagur
force-pushed
the
fix-poll-read-control-message-loop
branch
from
December 3, 2026 04:25
51e14fe to
397c5c3
Compare
After consuming a control message with a raw `recvmsg`, `poll_read` couldn't know whether the socket had more to offer, and the raw syscall registers no interest with the runtime, so it woke its own waker and returned `Pending` -- forcing an unnecessary reschedule and extra poll for every ignored control message (such as a TLS 1.3 NewSessionTicket). Extract control-message handling into `KtlsStream::handle_control_message` returning a two-variant `ControlMessageOutcome` (`Continue` or `Eof`), and restructure `poll_read` as a loop that polls the inner IO again on `Continue`. Also use `libc::EIO` instead of the magic constant `5`, and drop the unnecessary self-wake on the drained-data path, which already returns `Ready` immediately. The control-message handling logic itself is unchanged.
ArniDagur
force-pushed
the
fix-poll-read-control-message-loop
branch
from
December 3, 2026 04:31
397c5c3 to
f873d78
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After consuming a control message with a raw
recvmsg,poll_readcouldn't know whether the socket had more to offer, and the raw syscall registers no interest with the runtime, so it woke its own waker and returnedPending— forcing an unnecessary reschedule and extra poll for every ignored control message (such as a TLS 1.3NewSessionTicket).This PR restructures
poll_readas a loop:KtlsStream::handle_control_message, keeping theread_closed/write_closed/send_close_notifyside effects in place and returning a two-variantControlMessageOutcome(ContinueorEof).poll_read, polling the inner IO again onControlMessageOutcome::Continueso it either makes progress (data or another control message) or registers the waker directly.5withlibc::EIO.cx.waker().wake_by_ref()on the drained-data path, which already returnsPoll::Ready(Ok(())).The control-message handling logic itself is unchanged. Best viewed with "Hide whitespace" enabled.