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 latent bug in MqttApplicationMessageBuilder.WithPayload stream overload #1322

Merged
merged 1 commit into from
Jan 4, 2022

Conversation

gfoidl
Copy link
Member

@gfoidl gfoidl commented Jan 3, 2022

Stream.Read can read less than requested bytes, so we need read in a loop until either the requested byte-count is read or 0 is returned.

It's hard to construct a proper test for this, but that behavior is documented.

@chkr1011
Copy link
Collaborator

chkr1011 commented Jan 4, 2022

Thank you for your contribution. Good work 👍

@chkr1011 chkr1011 merged commit d981294 into dotnet:master Jan 4, 2022
chkr1011 added a commit that referenced this pull request Jan 4, 2022
@gfoidl gfoidl deleted the messagebuilder_stream_fix branch January 4, 2022 18:38
@jogibear9988
Copy link

wouldn't it be better to only start a loop when the first read returns less bytes?

@gfoidl
Copy link
Member Author

gfoidl commented Jan 4, 2022

@jogibear9988 that's basically done with the do-while loop.

It reads, and when read less than expected, so loop.

@jogibear9988
Copy link

I only thought it would maybe more effective. But I've not analyzed the IL...
So. OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants