Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Unable to watch more than 64 directories on Windows #70

Open
shesmer opened this issue Apr 30, 2015 · 0 comments
Open

Unable to watch more than 64 directories on Windows #70

shesmer opened this issue Apr 30, 2015 · 0 comments

Comments

@shesmer
Copy link

shesmer commented Apr 30, 2015

I am using pathwatcher in my own component and love it. I was using it the other day in a bigger project and all of the sudden I wasn't getting any notifications anymore.

After debugging pathwatcher it turns out to be a limitation in the Windows API that pathwatcher uses:

    DWORD r = WaitForMultipleObjects(copied_events.size(),
                                     copied_events.data(),
                                     FALSE,
                                     INFINITE);

in function PlatformThread() in pathwatcher_win.cc

Luckily there is a workaround to this problem given in the documentation on MSDN
https://msdn.microsoft.com/en-us/library/windows/desktop/ms687025(v=vs.85).aspx

To wait on more than MAXIMUM_WAIT_OBJECTS handles, use one of the following methods:

  1. Create a thread to wait on MAXIMUM_WAIT_OBJECTS handles, then wait on that thread plus the other handles. Use this technique to break the handles into groups of MAXIMUM_WAIT_OBJECTS.
  2. Call RegisterWaitForSingleObject to wait on each handle. A wait thread from the thread pool waits on MAXIMUM_WAIT_OBJECTS registered objects and assigns a worker thread after the object is signaled or the time-out interval expires.

Can this be fixed please ?

Btw, with your 65th directory the PlatformThread() function ends up in a continuous loop that uses 100% CPU as the function doesn't wait anymore but returns immediately. At a minimum the code should check the size and not pass in more than 64 objects.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant