Skip to content

io::copy: don't poll the reader again after eof while waiting for the writer to flush #894

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

Merged
merged 1 commit into from
Jun 21, 2022

Conversation

jbr
Copy link
Contributor

@jbr jbr commented Oct 15, 2020

I'm not entirely sure if this is a bug or just unexpected behavior, but I thought I'd write a quick PR just in case. Prior to this PR, io::copy continues to poll the reader after it has already returned Poll::Ready(Ok(0)) in the situation where the writer's flush is not immediately Ready. This resulted in a bug with a Read implementation that expected not to be read again after it returned eof. Removing the after-eof polling might save someone else from some confusion

@jbr jbr requested a review from dignifiedquire October 17, 2020 00:03
@joshtriplett
Copy link
Contributor

@jbr Could you add a test for this, with some artificially constructed futures? The artificial read future can panic if it gets polled after EOF.

@jbr jbr force-pushed the dont-poll-after-eof-in-io-copy branch from 1c9e8c1 to e94ff00 Compare June 2, 2022 19:03
@jbr jbr requested a review from joshtriplett June 2, 2022 19:04
@jbr
Copy link
Contributor Author

jbr commented Jun 2, 2022

Confirmed locally that the test does in fact fail with the changes to async_std::io::copy stashed

@jbr
Copy link
Contributor Author

jbr commented Jun 2, 2022

I do think it's worth figuring out if this was a bug previous to this commit. It was unspecified in documentation, and it's unclear if someone might be relying on the "continues to poll after eof" behavior, although that seems unlikely. I think this change is worth making either way, but the question is whether it's a breaking change or a bugfix

@jbr jbr force-pushed the dont-poll-after-eof-in-io-copy branch from e94ff00 to ae817ca Compare June 2, 2022 22:32
Copy link
Member

@Fishrock123 Fishrock123 left a comment

Choose a reason for hiding this comment

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

I think this is a bug fix.

@yoshuawuyts yoshuawuyts merged commit 21b72eb into async-rs:main Jun 21, 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.

4 participants