Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was 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

Description

@shesmer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions