Prevent infinite attempts to write to Win32 pipes #796
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.
#781 set the
PIPE_NOWAIT
flag on pipes in an attempt to get posix-like semantics. However, Windows will immediately return0
fromWriteFile
if the entire write would not complete. This means that asking to write more bytes than the size of the pipe's buffer will never do anything. The same applies to asking to write more bytes than is left available in the buffer.This change keeps #781's
PIPE_NOWAIT
and brings back some of its pipe buffer size checking logic, with the caveat to be careful with trustingFILE_PIPE_LOCAL_INFORMATION.WriteQuotaAvailable
since we've seen it return 0 when a reader is blocked waiting on the other end of the pipe.Fixes swiftlang/sourcekit-lsp#752