Conversation
- _oni_read_buffer was called twice in oni_read_frame: once for the frame header with allow_refill=1, and once for the payload with allow_refill=0. The flag was necessary because a second refill during the payload read would change ctx->shared_rbuf, breaking the single-buffer invariant that frames depend on. - The flag is unnecessary because _oni_read_buffer already refills to block_read_size bytes, and block_read_size >= max_read_frame_size >= max_data_size. After the header read the buffer is always guaranteed to hold the full payload, so a second refill can never occur. The payload read is now inlined in oni_read_frame. - The ONI_ENOREADDEV guard for max_read_frame_size == 0 is moved into _oni_read_buffer, which already uses that field as a refill threshold, making the function self-contained and allowing the NULL check on shared_rbuf within _oni_read_buffer to be removed.
Collaborator
|
Since we are moving towards unnecessary parameters, and since now Maybe just rename it to something like Right now it reads the payload through the |
- _oni_ensure_read_buffer is now a pure helper function that stictly refills the data buffer when required and does nothing otherwise - Referencing data within the buffer to create data frame elements is now performed in oni_read_frame - Other small changes to address compiler warnings and code consistency
Member
Author
|
This should be addressed in the latest commit. |
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.
_oni_read_buffer was called twice in oni_read_frame: once for the frame header with allow_refill=1, and once for the payload with allow_refill=0. The flag was necessary because a second refill during the payload read would change ctx->shared_rbuf, breaking the single-buffer invariant that frames depend on.
The flag is unnecessary because _oni_read_buffer already refills to block_read_size bytes, and block_read_size >= max_read_frame_size >= max_data_size. After the header read the buffer is always guaranteed to hold the full payload, so a second refill can never occur. The payload read is now inlined in oni_read_frame.
The ONI_ENOREADDEV guard for max_read_frame_size == 0 is moved into _oni_read_buffer, which already uses that field as a refill threshold, making the function self-contained and allowing the NULL check on shared_rbuf within _oni_read_buffer to be removed.