Skip to content

Conversation

@tristanlabelle
Copy link
Contributor

@tristanlabelle tristanlabelle commented Mar 3, 2023

libdispatch depends on non-blocking writes to retry later. For pipes on Windows, we achieved this using NtQueryInformationFile to get the WriteQuotaAvailable for the pipe, but this function returns 0 when there is a blocking read on the receiver side (this appears to be an OS bug), which causes us to never proceed to the write.

This change rather sets PIPE_NOWAIT on the pipe's write handle, similar to what is done on other platforms. This call will fail if the pipe handle does not have FILE_WRITE_ATTRIBUTES set, which is not a problem with the typical case of using a Foundation.Pipe. If we cannot set PIPE_NOWAIT, we will proceed with blocking writes, which in some circumstances could lead to hangs.

This resolves an issue with SourceKit-LSP on Windows where tests and real-life scenarios would hang because a pipe could never be written to.

@tristanlabelle tristanlabelle marked this pull request as ready for review March 6, 2023 20:51
@compnerd
Copy link
Member

compnerd commented Mar 6, 2023

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Mar 7, 2023

@swift-ci please test Windows platform

1 similar comment
@compnerd
Copy link
Member

compnerd commented Mar 7, 2023

@swift-ci please test Windows platform

@compnerd
Copy link
Member

compnerd commented Mar 7, 2023

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Mar 8, 2023

@swift-ci please test Windows platform

@compnerd
Copy link
Member

compnerd commented Mar 8, 2023

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Mar 8, 2023

@swift-ci please test Windows platform

@tristanlabelle
Copy link
Contributor Author

I ran tests locally. 22/22 passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants