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

rx read hangs because of redundant/excessive try_recv() #219

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

gopakumarce
Copy link
Contributor

If self.remaining_data is 0, recv_data() calls poll_next() which will do a try_recv() and bring in and decode the frame. And right after that we end up doing poll_data() which will again do a try_recv and this time it can end up hanging if the other end has not sent any more data. poll_data clearly checks if self.remaining_data is NON-ZERO at the top of that API, so before calling try_recv() it KNOWS that there is data to be read. So even if try_recv() says pending, it can/should go ahead and pull in the existing data.

If self.remaining_data is 0, recv_data() calls poll_next() which
will do a try_recv() and bring in and decode the frame. And right
after that we end up doing poll_data() which will again do a try_recv
and this time it can end up hanging if the other end has not sent
any more data. poll_data clearly checks if self.remaining_data is
NON-ZERO at the top of that API, so before calling try_recv() it
KNOWS that there is data to be read. So even if try_recv() says
pending, it can/should go ahead and pull in the existing data.
@seanmonstar
Copy link
Member

Thanks! Is this something that would be simple to add a unit test for? Or is it hard to test locally because it's related to buffers and latency?

@gopakumarce
Copy link
Contributor Author

Thanks! Is this something that would be simple to add a unit test for? Or is it hard to test locally because it's related to buffers and latency?

@seanmonstar it should be UT-able, let me explore the UT ecosystem in h3 and add one for this, will update the PR

@gopakumarce
Copy link
Contributor Author

Thanks! Is this something that would be simple to add a unit test for? Or is it hard to test locally because it's related to buffers and latency?

@seanmonstar it should be UT-able, let me explore the UT ecosystem in h3 and add one for this, will update the PR

@seanmonstar I have pushed a unit test case for this - I have ensured that the case "hangs" without the fix and works fine post the fix

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Excellent work, thanks for catching this and the test so we don't regress in the future!

@seanmonstar seanmonstar merged commit a530808 into hyperium:master Dec 15, 2023
10 checks passed
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.

2 participants