rjeczalik / notify

File system event notification library on steroids.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

readdcw: watching hangs forever if GetQueuedCompletionStatus returns zero transferred bytes

FabianKramm opened this issue · comments

Hello! I'm one of the maintainers of devspace, where we use notify as a file watcher in our synchronization functionality. Under some unclear circumstances the notify library seems to stop watching without any errors on windows in heavy load scenarios (several hundred file changes at once).

I investigated the problem and the issue seems to be in the function loop in the file watcher_readdcw.go. In the special case the windows api function GetQueuedCompletionStatus retrieves zero bytes in lpNumberOfBytes. This leads to the skip of calling the readdirchanges function, since n is zero:

if n != 0 {
	r.loopevent(n, overEx)
	if err = overEx.parent.readDirChanges(); err != nil {
		// TODO: error handling
	}
}

Which in the next loop iteration leads to the subsequent execution of GetQueuedCompletionStatus, which will hang forever. The solution is pretty simple, just call readDirChanges when n is zero. I created a pull request for this issue.

Thanks for the awesome library!