Conversation
This was referenced Sep 20, 2024
timvisee
reviewed
Sep 23, 2024
|
|
||
| impl Write for WriteBox { | ||
| fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
| if !self.enabled.load(Ordering::Relaxed) { |
Member
There was a problem hiding this comment.
Don't we need release/acquire here to prevent reordering incorrectly?
|
|
||
| impl Write for WriteBox { | ||
| fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
| if !self.enabled.load(Ordering::Relaxed) { |
Member
There was a problem hiding this comment.
Do I understand it correctly: the tar impl will attempt to write the final 1K zero bytes. But this write will be rejected here if we unset the enabled flag, preventing the panic?
If we explicitly finalize ourselves the tar impl doesn't write anything and we don't hit this branch at all (during drop).
- Generalize: instead of taking `std::fs::File`, take `impl Write + Seek`. - Add a workaround for drop: `tar::Builder<W>::drop` might panic if the underlying writer panics when using in async context.
10e4768 to
e80a392
Compare
This was referenced Oct 4, 2024
generall
approved these changes
Oct 4, 2024
generall
pushed a commit
that referenced
this pull request
Oct 8, 2024
* tar_ext::BuilderExt: generalize and add drop workaround - Generalize: instead of taking `std::fs::File`, take `impl Write + Seek`. - Add a workaround for drop: `tar::Builder<W>::drop` might panic if the underlying writer panics when using in async context. * Drop unnecessary write_fn usage * tar_ext::BuilderExt: support both seekable and streaming variants * tar_ext::BuilderExt: support both owned/borrowed variants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates
tar_ext::BuilderExtwith the following changes:std::fs::File, takeimpl Write + Seek. Later this requirement will be reduced further toimpl Writeto support bothFileand an async stream (SyncIoBridge).tar::Builder<W>::dropmight panic if the underlying writer panics when using in async context. See a comment forBuilderBoxand newly added unit tests for more details on the issue.