Skip to content

Fix WriteFmtFuture not taking into account already written bytes (#964) #965

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
Apr 2, 2021
Merged

Fix WriteFmtFuture not taking into account already written bytes (#964) #965

merged 1 commit into from
Apr 2, 2021

Conversation

rkarp
Copy link
Contributor

@rkarp rkarp commented Mar 13, 2021

Fixes #964. The problem is that amt (amount of bytes already written) is ignored, so on every poll the whole buffer is sent again if it was not possible to write the whole buffer on the first poll. Interestingly, for some cases other than File, all bytes get written on the first poll, which is probably why this bug hasn't been noticed before.

The actual fix is just line 44, but converting from u64 to usize for array indexing requires a checked conversion and I couldn't see any reason in the code why amt has to be u64, so I changed the type to avoid something like try_into().unwrap().

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.

This is great, thanks so much!

@yoshuawuyts yoshuawuyts merged commit 35f7681 into async-rs:master Apr 2, 2021
@rkarp rkarp deleted the fix-write-fmt-future branch April 3, 2021 12:48
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.

multiple write! on async_std::fs::File can trigger infinite process
2 participants