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

Fix Read() with count=0 exhausting MessageBodyStream #4295

Merged
merged 2 commits into from
Jul 23, 2020

Conversation

mriehm
Copy link
Contributor

@mriehm mriehm commented Jun 7, 2020

Fixes #4281

@HongGit HongGit requested review from mconnew and HongGit June 9, 2020 22:20
@mconnew
Copy link
Member

mconnew commented Jun 9, 2020

@mriehm, thank you for this. Can you add a similar check in the ReadAsync method too?

@mconnew
Copy link
Member

mconnew commented Jun 9, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mriehm
Copy link
Contributor Author

mriehm commented Jun 9, 2020

Sure. Done.

ReadAsync() appears to be just a wrapper for Read(), so I don't know if adding the check to ReadAsync() itself is behaviorally required, but it may be a performance optimization.

@mconnew
Copy link
Member

mconnew commented Jul 22, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mconnew
Copy link
Member

mconnew commented Jul 22, 2020

@mriehm, the async read does an async pre-read before synchronously reading. This is because the read goes through a serializer which is sync only. The pre-read is to make and effort to fill a buffer hoping it's enough and can be done asynchronously. It's a best effort attempt to try and get things to actually happen async.
I'll merge this as soon as the tests pass. The failure was nothing to do with your change.

@mconnew
Copy link
Member

mconnew commented Jul 23, 2020

Test which is failing is due to needing an updated version of the testserver being deployed and this PR is based off an older commit. This should be safe to merge so merging despite test failures.

@mconnew mconnew merged commit 2aec844 into dotnet:master Jul 23, 2020
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.

MessageBodyStream.Read() with count=0 unexpectedly terminates Stream
2 participants