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

Use Stream.Read instead of .ReadByte for the first byte #1142

Closed
wants to merge 2 commits into from

Conversation

HoloRin
Copy link

@HoloRin HoloRin commented Feb 9, 2022

It appears that on occasion Stream.ReadByte can hang unexpectedly. Maybe Stream.Read does not suffer this issue?

Intended to address #1140

@HoloRin HoloRin requested a review from lukebakken February 9, 2022 08:44
@lukebakken lukebakken force-pushed the rabbitmq-dotnet-client-1140 branch from dc21bb3 to 5be4196 Compare February 9, 2022 14:31
{
throw new MalformedFrameException("Invalid AMQP protocol header from server");
}
byte[] buf = new byte[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a static reusable buffer, and instead try to read 7 bytes instead of multiple Read calls. It'll simplify the code a lot.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you didn't read 7 bytes you can immediately throw the MalformedFrameException. If you did read 7 bytes, continue with the processing as the old code does.

@lukebakken
Copy link
Contributor

lukebakken commented Feb 14, 2022

@stebet thanks for the review. FYI we're trying to resolve #1140 if you have any ideas there. I don't think this PR fixes the issue just yet.

Also, the test is still flaky in main and it reads in the manner you suggest, so I think we'll focus on a fix there.

HoloRin and others added 2 commits February 14, 2022 09:41
It appears that on occassion ReadByte can hang unexpectedly. Maybe
Read does suffer this issue?
@lukebakken lukebakken force-pushed the rabbitmq-dotnet-client-1140 branch from 69ba26b to 3f7bd11 Compare February 14, 2022 17:42
@lukebakken
Copy link
Contributor

The flaky tests exist on main, and inbound frames are read in a similar manner to what is attempted here. I'm going to focus on diagnosis on that branch first.

@lukebakken lukebakken closed this Feb 14, 2022
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