Repository navigation
Write to stdout and stderr without a lock for a single write - #408
Merged
Merged
Conversation
A Stdout or Stderr write already takes the lock for itself, so locking around one writeln! only adds code. The locks that cover several writes stay, so that their output is not interleaved. Fixes #406
Collaborator
|
Thanks for your PR |
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.
Fixes #406
Thanks @oech3 for the report.
A
Stdout/Stderrwrite already takes the lock for itself, so locking around a singlewriteln!adds code and does nothing else.let _ =error handling is kept everywhere.Changed (one write per lock):
src/bin/shadow-rs.rs: the argv[0] mismatch message (the example in the issue)src/shadow-core/src/pam.rs: the PAM text-info messagesrc/shadow-core/src/tty.rs: the stderr prompt fallback.write_promptmakes onewrite_all, itsflushis a no-op on unbuffered stderr, and the trailing newline is a separate single writesrc/uu/passwd/src/passwd.rs:passwd: password changed.src/uu/gpasswd/src/gpasswd.rs: the add/remove message.-aand-dare mutually exclusive, so the lock never covered more than one writeKept (the lock covers several writes):
print_multicall_helpandprint_available_utilsin shadow-rs.rs,chageinteractive prompts and-l,chsh -l,passwd -S/-Sa,useradd -D, thevipwnotice, and the completions generator.Size of the multicall release binary (
cargo build --release --features pam, Debian container): 2,270,440 -> 2,268,072 bytes (-2,368).Checked in the Debian container:
cargo test --workspace(1065 passed, 0 failed),cargo clippy --workspace --all-targets -- -D warningswith and without--features pam, andcargo fmt --all --check.Reviews welcome. Without objection, this will be merged after 7 days.