Skip to content
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

Fixed #831: changed several cases where a shared readerIndex was changed #832

Merged
merged 2 commits into from Apr 30, 2024

Conversation

hylkevds
Copy link
Collaborator

DebugUtils.payload2Str set the readerIndex to the readableBytes, witch was simply wrong.

Utils.readBytesAndRewind was unused and thus removed. Though it changed the readerIndex, it also reset it, but this use would still have not been thread-safe.

SegmentedPersistentQueueSerDes use of readBytes (that changes the readerIndex) was changed to getBytes which does not change the readerIndex.

Closes #831

@hylkevds hylkevds requested a review from andsel April 28, 2024 17:58
@andsel
Copy link
Collaborator

andsel commented Apr 29, 2024

Hi @hylkevds thanks for working on this fix.

DebugUtils.payload2Str set the readerIndex to the readableBytes, witch was simply wrong.

You are right, should be readerIndex(), if the buffer isn't shared.

All changes look good, but would be nice to have this covered by a unit test, because or code wasn't tested or the coverage of these lines was not so complete and the bug didn't pop up.

DebugUtils.payload2Str set the readerIndex to the readableBytes, witch
was simply wrong. Utils.readBytesAndRewind was unused and thus removed.
SegmentedPersistentQueueSerDes use of readBytes (that changes the
readerIndex) was changed to getBytes which does not change the readerIndex.
@hylkevds
Copy link
Collaborator Author

The writePayload one is testable, added a test for it.

Copy link
Collaborator

@andsel andsel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andsel andsel merged commit 858a0f3 into moquette-io:main Apr 30, 2024
4 checks passed
@andsel
Copy link
Collaborator

andsel commented Apr 30, 2024

Thank's for contributing the fix @hylkevds

@hylkevds hylkevds deleted the fix_831_readerIndex branch April 30, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shrared buffer issues due to readerIndex
2 participants