FileWatcher.cpp: continue monitoring a watched dir for changes even if a buffer overflow nullified one notification #3846
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the function ReadDirectoryChangesNotification the parameter bytesTransfered may be zero, presumably indicating an overflow: the buffer was too small to contain all the change notifications that have accumulated, in which case these notifications are discarded. But we should keep on monitoring the watched dir for future changes as we would do when handling a normal notification. The original code didn't do that, and this is what I've fixed.
This change solves the problem of Sumatra not reloading PDF files in situations where other files in the same directory are being repeatedly changed very frequently, which creates a race condition that may lead to a buffer overflow. If needed I can provide more details on the circumstances under which I came across this problem.
Thanks!