Skip to content

Fix file EOF to not be permanent: reading again should give new data #1030

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

Conversation

joshtriplett
Copy link
Contributor

@joshtriplett joshtriplett commented Jun 20, 2022

async_std::fs::File currently has a bug that makes EOF a permanent condition:
once the File has encountered EOF, it will continue to return EOF even if new
data gets added to the file.

Discovered when trying to convert some code from smol to async_std. The
code depends on having multiple File objects referring to the same disk file,
appending to one, and expecting the other to be able to read the new data.

Fix the File implementation to address this, and add a test to verify this behavior.

Go back to the idle mode when returning EOF, so that the next read will
make another attempt to read from the file in case the file grew.
@joshtriplett joshtriplett force-pushed the file-eof-should-not-be-permanent branch from 858b24b to dfdf56c Compare June 30, 2022 09:06
@joshtriplett joshtriplett changed the title Test that file EOF is not permanent: reading again should give new data Fix file EOF to not be permanent: reading again should give new data Jun 30, 2022
Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

Thanks so much for chasing this down!

@joshtriplett joshtriplett merged commit c6b2128 into async-rs:main Jul 1, 2022
@joshtriplett joshtriplett deleted the file-eof-should-not-be-permanent branch July 1, 2022 22:31
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