-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Flush BufWriter
s, clean up error reporting
#7622
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
Conversation
Write errors led with `tr: tr: write error:`.
351a0ec
to
a9cd3f1
Compare
GNU testsuite comparison:
|
We pass a `&mut dyn Write` in anyway, but now that's entirely up to the caller.
GNU testsuite comparison:
|
do you know if it impacts performances? thanks |
There shouldn't be any performance impact. They're already flushed automatically on drop, with this change we flush them manually before dropping so we can handle the errors. The docs say it's "critical" to call flush: https://doc.rust-lang.org/std/io/struct.BufWriter.html |
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.
Great!
A
BufWriter
must be flushed when you're done with it, since it'll ignore any write errors when it flushes on dropping. So many utilities would ignore write errors for small outputs. I went through all theBufWriter
s to add this where it was missing. (Exceptshuf
, which is handled in #7585.)I also cleaned up some error reporting as I went.
sort
used to panic on write errors and some other utilities added weird context to errors or no context at all.All the added flushes have Linux-only tests that use
/dev/full
. That seemed the easiest way to do it.