-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Avoid writes without any data in Write::write_all_vectored
#74088
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
while !bufs.is_empty() { | ||
match self.write_vectored(bufs) { | ||
Ok(0) => { | ||
return Err(Error::new(ErrorKind::WriteZero, "failed to write whole buffer")); | ||
} | ||
Ok(n) => bufs = IoSlice::advance(mem::take(&mut bufs), n), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes me happy this is possible now :)
@Thomasdezeeuw @tmiasko This is a triage bump. |
r? @KodrAus |
I’m not very familiar with this API, but @tmiasko do you expect this unconditional advance to have any perf impact for the more common case of non-empty buffers? |
I would expect the impact to be negligible compared to any I/O involved, and changes necessary regardless of the impact. |
Previously, when non-empty sequence of empty IoSlices have been provided to `Write::write_all_vectored`, the buffers would be written as is with `Write::write_vectored` and subsequently the return value `Ok(0)` would be misinterpreted as an error. Avoid writes without any data by advancing the buffers first. This matches the documented behaviour of `Write::write_all_vectored` and is analogous to what happens in `Write::write_all`.
f1bf504
to
7a5d3ab
Compare
@bors r+ rollup |
📌 Commit 7a5d3ab has been approved by |
…=KodrAus Avoid writes without any data in `Write::write_all_vectored` Previously, when non-empty sequence of empty IoSlices have been provided to `Write::write_all_vectored`, the buffers would be written as is with `Write::write_vectored` and subsequently the return value `Ok(0)` would be misinterpreted as an error. Avoid writes without any data by advancing the buffers first. This matches the documented behaviour of `Write::write_all_vectored` and is analogous to what happens in `Write::write_all`.
Rollup of 6 pull requests Successful merges: - rust-lang#74088 (Avoid writes without any data in `Write::write_all_vectored`) - rust-lang#74598 (Fix sync_once_cell_does_not_leak_partially_constructed_boxes) - rust-lang#74750 (Clean up some uses of logging in ui tests) - rust-lang#74783 (python codes cleanup) - rust-lang#74790 (Don't italicize comments in ayu theme) - rust-lang#74799 (Fixed typo in `closure`) Failed merges: r? @ghost
Previously, when non-empty sequence of empty IoSlices have been provided
to
Write::write_all_vectored
, the buffers would be written as is withWrite::write_vectored
and subsequently the return valueOk(0)
wouldbe misinterpreted as an error.
Avoid writes without any data by advancing the buffers first. This
matches the documented behaviour of
Write::write_all_vectored
and is analogous to what happens in
Write::write_all
.