-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a mode to the receive buffer to handle external buffers #4758
base: main
Are you sure you want to change the base?
Conversation
e7d3261
to
07dc4d9
Compare
07dc4d9
to
06d5bcf
Compare
src/core/recv_buffer.h
Outdated
@@ -22,9 +25,19 @@ typedef struct QUIC_RECV_CHUNK { | |||
CXPLAT_LIST_ENTRY Link; // Link in the list of chunks. | |||
uint32_t AllocLength : 31; // Allocation size of Buffer | |||
uint32_t ExternalReference : 1; // Indicates the buffer is being used externally. | |||
uint8_t Buffer[0]; | |||
uint8_t *Buffer; // Pointer to the buffer itself. Doesn't need to be freed independently: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat independent of this PR, I am wondering if we could/should annotate this pointer:
uint8_t *Buffer; // Pointer to the buffer itself. Doesn't need to be freed independently: | |
_Field_size_bytes_(AllocLength) | |
uint8_t *Buffer; // Pointer to the buffer itself. Doesn't need to be freed independently: |
src/core/recv_buffer.c
Outdated
QuicRecvChunkInitialize( | ||
_Inout_ QUIC_RECV_CHUNK* Chunk, | ||
_In_ uint32_t AllocLength, | ||
_In_ uint8_t* Buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe improve the annotation a bit more? I think this is it:
_In_ uint8_t* Buffer | |
_In_updates_(AllocLength) uint8_t* Buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I also need to add the corresponding annotations on the chunk struct itself.
src/core/recv_buffer.c
Outdated
// External chunks can be provided only if already in external mode, or if | ||
// nothing has been written to the buffer yet. | ||
// | ||
uint64_t rangeMax; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, our style capitalizes all variables and fields.
uint64_t rangeMax; | |
uint64_t RangeMax; |
Please update for everything else too. Thanks!
src/core/recv_buffer.c
Outdated
@@ -186,6 +262,7 @@ QuicRecvBufferResize( | |||
_In_ uint32_t TargetBufferLength | |||
) | |||
{ | |||
CXPLAT_DBG_ASSERT(RecvBuffer->RecvMode != QUIC_RECV_BUF_MODE_EXTERNAL); // Should never resize in external mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, we also have CXPLAT_DBG_ASSERTMSG
which could be used here instead of the comment:
CXPLAT_DBG_ASSERT(RecvBuffer->RecvMode != QUIC_RECV_BUF_MODE_EXTERNAL); // Should never resize in external mode | |
CXPLAT_DBG_ASSERTMSG(RecvBuffer->RecvMode != QUIC_RECV_BUF_MODE_EXTERNAL, "Should never resize in external mode"); |
But you don't have to use it. We don't use it that much.
src/core/recv_buffer.c
Outdated
@@ -573,24 +660,28 @@ QuicRecvBufferWrite( | |||
// N.B. We do this before updating the written ranges below so we don't have | |||
// to support rolling back those changes on the possible allocation failure | |||
// here. | |||
// This is skiped in external mode since the entire virtual length is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This is skiped in external mode since the entire virtual length is | |
// This is skipped in external mode since the entire virtual length is |
src/core/recv_buffer.c
Outdated
for (uint32_t i = 0; i < *BufferCount && remainingDataToRead > 0; ++i) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit:
for (uint32_t i = 0; i < *BufferCount && remainingDataToRead > 0; ++i) | |
{ | |
for (uint32_t i = 0; i < *BufferCount && remainingDataToRead > 0; ++i) { |
Description
As part of #4747, the receive buffer needs a mode to operate on buffers provided by the application.
This PR defines a new
QUIC_RECV_BUF_MODE_EXTERNAL
mode.QUIC_RECV_CHUNK
s now have a pointer to the actual buffer instead of an end-of-struct arrayTesting
Unit tests have been added
Documentation
To be done