Repository navigation
tail: fix following redirected stdin - #9093
mattsu2020 wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
|
The CI fail seems unrelated. Could you squash your commits, for us to review your work better, and prepare for the future merge? |
5e1957f to
7f3ecc7
Compare
|
GNU testsuite comparison: |
Done |
|
GNU testsuite comparison: |
1 similar comment
|
GNU testsuite comparison: |
beab632 to
05bdc56
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
ce85f5c to
b50b701
Compare
|
GNU testsuite comparison: |
b50b701 to
ab579ed
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
| return Ok(()); | ||
| } | ||
|
|
||
| if path.metadata().map(|meta| meta.is_dir()).unwrap_or(false) { |
There was a problem hiding this comment.
tail_file already handles directories, this duplicates it. could we just let it go there?
| } | ||
|
|
||
| #[allow(clippy::unnecessary_wraps)] | ||
| pub fn set_stdin_key<P: Into<PathBuf>>(&mut self, _path: P) -> UResult<()> { |
There was a problem hiding this comment.
i am really not a fan of this function.
it probably demonstrates a refactor
Merging this PR will improve performance by 21.05%1 warning, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
4ebd4de to
3b4a91f
Compare
3b4a91f to
0926e9f
Compare
|
GNU testsuite comparison: |
|
You need to annotate the test not to run on wasi |
|
thanks for picking this up! This does more than fix |
|
sorry but it needs to be rebased, and a bunch of jobs are failing |
9c7e4b9 to
6c3539b
Compare
6c3539b to
784c4f3
Compare
|
Binary size comparison: |
|
|
||
| if observer.use_polling && settings.follow.is_some() { | ||
| if settings.follow.is_some() && observer.use_polling { | ||
| // Consider all files to potentially have new content. |
There was a problem hiding this comment.
this also changes plain tail -f file when the file is moved (orphans re-read every loop, the follow_name() guard above, test_follow_descriptor_moved_while_other_file_changes). could you please split it into its own pr?
| return None; | ||
| } | ||
|
|
||
| String::from_utf16(&buffer[..len]).ok().map(PathBuf::from) |
There was a problem hiding this comment.
please use OsString::from_wide here, otherwise a non UTF-16 path is silently not followed.
same thing for paths longer than MAX_PATH
| 1, | ||
| translate!("tail-error-recv-timeout-error", "error" => e), | ||
| )); | ||
| } |
There was a problem hiding this comment.
why swap the two conditions?
| #[uutests::wasi_ignore(TailFollowDisabled)] | ||
| #[test] | ||
| #[cfg(unix)] | ||
| fn test_follow_descriptor_moved_while_other_file_changes() { |
There was a problem hiding this comment.
a writer thread plus atomics is a lot for a test, could it be simpler?
| EventKind::Modify(ModifyKind::Any | ModifyKind::Metadata(MetadataKind::Any | MetadataKind::WriteTime) | ModifyKind::Data(_) | ModifyKind::Name(RenameMode::To)) | | ||
| EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any) => { | ||
| if let Ok(new_md) = event_path.metadata() { | ||
| if follows_open_file { |
There was a problem hiding this comment.
this branch is also taken for plain tail -f file: with polling, a replaced file is no longer reopened, and a file replaced by something untailable no longer resets the reader.
could you please move that to #17002, or add tests for plain tail -f file here?
There was a problem hiding this comment.
I updated it to add more test cases.
| } else { | ||
| open_file(path, settings.use_nonblocking()) | ||
| }; | ||
| let open_result = open_file(path, settings.use_nonblocking()); |
There was a problem hiding this comment.
both cfg branches are the same now, could we drop the cfg?
ebb0774 to
6c8a5b2
Compare
Resolve and watch redirected stdin at read time and reuse its open descriptor, preserving the input offset and following the same file after renames, replacements, or truncation. Add regression tests for redirected stdin and descriptor following.
tail -f < fileexits after the initial read instead of following further appends. Resolve and watch redirected stdin at read time and reuse its open descriptor, preserving the input offset and following the same file after renames, replacements, or truncation.Add regression coverage for redirected stdin and descriptor following, with unsupported cases skipped on WASI.
Closes #7614