Skip to content

tail: report the follow mode actually used with --debug - #16670

Open
costajohnt wants to merge 2 commits into
uutils:mainfrom
costajohnt:fix/tail-debug-polling-mode
Open

costajohnt wants to merge 2 commits into
uutils:mainfrom
costajohnt:fix/tail-debug-polling-mode

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

--debug always printed using notification mode, once, before the initial output. Now the mode line comes when following actually starts, and it names the mode in use:

  • -f with no regular-file input (e.g. /dev/null, a piped stdin) prints using blocking mode, and -F on the same prints using polling mode, as in the issue.
  • When a watched directory is removed and tail reverts to polling, using polling mode follows inotify cannot be used, reverting to polling (once, even with several files in that directory).
  • No mode line is printed when following never starts (tail --debug -f missing).

Only the reported message changes for devices and FIFOs; the watcher underneath is the same.

The new tests cover the blocking and polling cases, the missing-file case and the switch to polling. The directory tests rename the directory before deleting its files and wait for tail's own output before the next step, so they don't depend on timing.

Closes #16643

--debug always printed "using notification mode", once, before the
initial output. Print the mode only once following actually starts,
report blocking mode (-f) or polling mode (-F) when no input (stdin
included) is a regular file, and report the switch to polling the first
time a watched directory is removed.

Closes uutils#16643
Comment thread src/uu/tail/src/follow/watch.rs Outdated
@@ -540,11 +548,37 @@ fn report_inaccessible(display_name: &str) {
}

#[allow(clippy::cognitive_complexity)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this allow now applies to print_follow_mode instead of follow, so clippy is red. please move the new fn above it

// already gone whenever tail handles the removal.
at.rename("dir", "dir.gone");
at.remove("dir.gone/f");
for _ in 0..100 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same wait loop is here 3 times, could you please add a small helper?

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for the PR!
print_follow_mode was added between #[allow(clippy::cognitive_complexity)] and follow(), so clippy fails on follow now (the wasm/msys lint jobs). please fix it and get CI green.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+108 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

Put the cognitive_complexity allow back on follow(), drop the WASI stub
Observer field that is no longer read, and classify stdin with fstat on
fd 0 instead of stat on /dev/stdin.
@costajohnt

Copy link
Copy Markdown
Contributor Author

Thanks! Moved the #[allow(clippy::cognitive_complexity)] back onto follow in 644bab1. Two other CI failures were from this PR too, so they're in the same commit:

  • wasm lint: the WASI stub Observer still had a use_polling field nothing read any more, so it's a unit struct now.
  • Android: the new piped-stdin --debug test printed "notification mode". The check stat'ed /dev/stdin, which doesn't map to fd 0 there, so it now uses fstat on stdin like args.rs does. It only changes which mode --debug reports, and on Linux the result is the same as before.

The MSYS failure (mv: cannot stat 'target/release-small/deps/stdbuf.dll') also shows up on unrelated PRs.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/tail/debug is no longer failing!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tail: --debug always says notification mode and misses the switch to polling

2 participants