mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tail: fix intermittent overlay-headers test by batching inotify events
This commit is contained in:
@@ -576,9 +576,17 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> {
|
||||
// Drain any additional pending events to batch them together.
|
||||
// This prevents redundant headers when multiple inotify events
|
||||
// are queued (e.g., after resuming from SIGSTOP).
|
||||
while let Ok(Ok(event)) = observer.watcher_rx.as_mut().unwrap().receiver.try_recv()
|
||||
{
|
||||
process_event(&mut observer, event, settings, &mut paths)?;
|
||||
// Multiple iterations with spin_loop hints give the notify
|
||||
// background thread chances to deliver pending events.
|
||||
for _ in 0..100 {
|
||||
while let Ok(Ok(event)) =
|
||||
observer.watcher_rx.as_mut().unwrap().receiver.try_recv()
|
||||
{
|
||||
process_event(&mut observer, event, settings, &mut paths)?;
|
||||
}
|
||||
// Use both yield and spin hint for broader CPU support
|
||||
std::thread::yield_now();
|
||||
std::hint::spin_loop();
|
||||
}
|
||||
}
|
||||
Ok(Err(notify::Error {
|
||||
|
||||
Reference in New Issue
Block a user