microsoft / windows-container-tools

Collection of tools to improve the Windows Containers experience
MIT License
236 stars 66 forks source link

[Fix] Log stream delay when dir does not exist #174

Closed TinaMor closed 1 month ago

TinaMor commented 1 month ago

What does this PR do?

This PR fixes LogMonitor tool missing the first few log lines when the log file and directory are created after the LogMonitor tool has started. Issue #170

This regression is caused by the PR #149. The WaitForMultipleObjects() function waits until the timer expires even though the object is already created during the wait interval.

Summary of Fix

The fix adds a waitable object on the directory that the LogMonitor tool is observing. The WaitForMultipleObjects() function waits until either the timer expires or the specified file is created. By including the handle of the waitable object in the array, the function can return as soon as the file is created.

This way, the system does not have to wait for the entire duration specified by the timer if the file is created during the wait period. This makes the file monitoring more responsive and efficient.

bobsira commented 1 month ago

File Test I've just tested this change in a container and it appears everything runs fine! I'll do a locally run to see if there is any issue!