[ul] BUG: Share underlying buffer from client/server to PDataReader#606
Merged
Enet4 merged 4 commits intoEnet4:masterfrom Dec 7, 2024
Merged
[ul] BUG: Share underlying buffer from client/server to PDataReader#606Enet4 merged 4 commits intoEnet4:masterfrom
PDataReader#606Enet4 merged 4 commits intoEnet4:masterfrom
Conversation
By creating a new read buffer in PDataReader, we potentially miss out on any bytes that the `receive()` method read but didn't process yet. Additionally, we lose the opposite when returning out of `PDataReader`: remaining data in the PDataReader buffer that it didn't process. The solution here is to mutably share that underlying read buffer with the `PDataReader` so that it can continue from where the `receive()` method left off _and_ pass any data that it didn't read back to the read buffer of the main `Client` or `Server` object.
Contributor
Author
|
Fixes #604 |
Enet4
approved these changes
Dec 7, 2024
Owner
Enet4
left a comment
There was a problem hiding this comment.
Thank you for looking into this. I had identified a few places where the lack of buffer sharing could cause issues, but this one was probably overlooked, even though it is important.
Somewhat related, but not caused by this PR, I found that the current fuzz target test in ul/fuzz fails, so there may still be some bugs in the new PDU reading/writing impls. Hopefully there will be more opportunities to track them down. But for now, it looks good to be merged. Thanks! 👍
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.
By creating a new read buffer in PDataReader, we potentially miss out on
any bytes that the
receive()method read but didn't process yet.Additionally, we lose the opposite when returning out of
PDataReader:remaining data in the PDataReader buffer that it didn't process.
The solution here is to mutably share that underlying read buffer with the
PDataReaderso that it can continue from where thereceive()methodleft off and pass any data that it didn't read back to the read buffer
of the main
ClientorServerobject.