tail: fix intermittent overlay-headers test by batching inotify events

This commit is contained in:
Sylvestre Ledru
2025-12-08 07:59:02 +01:00
parent 67ede852a0
commit 61e83a1c86
+11 -3
View File
@@ -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 {