connmgr: add ability to send large response headers#48372
Merged
Conversation
feb75a8 to
9fdc43e
Compare
9fdc43e to
990be5a
Compare
990be5a to
718af0b
Compare
clintjedwards
approved these changes
Jun 22, 2026
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.
Similar to #48368, this adds support for sending large headers in the other direction.
Currently, response headers are first written to the task's write buffer, and then the content of that buffer is written to the client socket. With this change, the response headers are written directly to the client socket, allowing headers of arbitrary size to be sent.
This change also obsoletes the "overflow" feature for response body data, whereby any initial body data (up to the buffer size) that can't fit alongside the header data within the task's write buffer spills over into a separate heap-allocated buffer. For example, if the write buffer size is 16k and the header data is 4k, then up to 16k of initial body data will be allowed but only 12k will be able to fit alongside the header data in the write buffer, in which case a temporary 4k heap allocation will be used to hold the remaining initial body. Now that we no longer write the header data to the buffer, the allowed initial body data always fits in it, and thus the
preparemethod always returns an overflowed byte count of zero.As before, we have to move some variables around in the server connection tasks to ensure they live for the duration of header sending. Part of this involves keeping some variables higher up in the call stack where they are not yet used and then passing down mutable references to them. For example, the IPC message carrying response data is received deep in the call stack and then moved via reference into a variable that lives higher in the call stack, allowing data to be returned that borrows from the message. This works because the message has been moved out of the function and can survive the function returning. These kinds of params that the callee fills in but are not directly used by the caller afterwards are often labeled as "scratch" params, to differentiate them from "out" params.
Also, as before, moving variables around causes the task sizes to increase, so the size thresholds are updated. I'll take a look at optimizing the sizes afterwards, if at all possible.
Relatedly, keeping an IPC message around for the duration of sending its contents to the client requires excluding it from our special tracking mechanism. The
trackmodule is used to enforce lifetimes of IPC messages, such that only one tracked message exists at a time per task and that the message is processed timely. This PR adds aninto_innermethod toTrack, making it possible for a task to optionally exclude a message from tracking. We didn't need to do this earlier for request headers since the IPC message acting as the source data for outbound requests already begins in an untracked state.