Refactor: Move V1L private pointer from wrk to the vdp entry #4219
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.
The http1 line layer V1L is a bit special in that it is first used to send1 http headers and then, optionally, used as a delivery processor (VDP) to send the body.
Historically, V1L was contained directly in
struct worker
under the name WRW and when it got separated, it retained its private pointer directly instruct worker
.From today's perspective and with the advent of more protocol support, having this special case seems like an anachronism, because we have everything in place to not require it.
This PR consists of two patches. The first prepares the ground by simple refactoring of
V1L_Open()
to return thestruct v1l *
rather than storing it in thestruct worker
itself. It contains some transient code to updatestruct worker
outsideV1L_Open()
, this is only done to enable the split into two patches.The actual change is in the second patch, which implements the goal of removing the
v1l
member fromstruct worker
. This necessarily (but trivially) changes the V1L related function signatures, so the textual diff might look like a mouthful. But most of it is simple, really:V1L_Close()
to take astruct v1l **
VDP_Push()
to pass thestruct v1l *
as the private pointerstruct v1l *
instead ofstruct worker *
One detail which remains special has to do with the duality of V1L remaining in place: Because
V1L_Close()
remains responsible for closing the v1l, the VDP layer must not touch it. For this interaction to work,V1L_Close()
needs to clear the private pointer in the VDP entry. The existing check inVDP_Close()
for the private pointer to be cleared implies a check for V1L to be closed before VDP, so we can be certain that when the VDP closes, V1L is already closed.Related note: Before this second iteration, I had also completed a patch series where V1L would be entirely moved under control of the VDP layer (that is, the VDP would need to be pushed whenever V1L was used, so also for the "no body" case), but I found this option too intrusive and implying too much overhead. So keeping V1L a bit special seemed like the better option.
Footnotes
"send" is a simplification, actually the whole point about using V1L for both header and body is to not write the headers to the HTTP1 connection individually, but rather batch both together into a single
writev()
call, if possible. ↩