Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix: poll stream until pending #2340

Merged
merged 1 commit into from
Apr 10, 2023

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Apr 10, 2023

Motivation

streams only register the waker if they're pending
Returning "pending" when the underlying stream is still ready does not ensure that the rt will poll again.

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

},
None => Poll::Ready(None),
let mut this = self.project();
loop {
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't this loop a no-op, as the return always ends it on the first loop?

Copy link
Collaborator

Choose a reason for hiding this comment

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

nvm i am misreading the code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This continues the poll rx on Err(err) instead of returning Pending, and ensures that the underlying stream is completely drained or returns a valid element.

Copy link
Collaborator

@prestwich prestwich left a comment

Choose a reason for hiding this comment

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

CI failures are unrelated

@prestwich prestwich merged commit feaca04 into gakonst:master Apr 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants