Fix ClonedServer_ActsAsOriginalServer test (#72698)
authorStephen Toub <stoub@microsoft.com>
Sat, 23 Jul 2022 02:45:25 +0000 (22:45 -0400)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 02:45:25 +0000 (22:45 -0400)
commitd5b718faf093453fc31759578a0fbce104fd8ea1
treeb27ed510631af3edd87ddf90227c070c5a83a3a2
parent1e1e86d34eee952c7c331bf002d928e0681942eb
Fix ClonedServer_ActsAsOriginalServer test (#72698)

We recently introduced a configuration of the pipe stream tests where named pipes are constructed with PipeOptions.None.  And in that configuration, the ClonedServer_ActsAsOriginalServer has started sporadically hanging.  It appears that the GetNamedPipeHandleStateW function called by NamedPipeClientStream.NumberOfServerInstances takes some lock that ReadFileW also holds while doing a synchronous read; as such, if the wrong interleaving of operations occurs, the queued work item that performs a read can end up blocking the assert check of NumberOfServerInstances from completing, and the test deadlocks.  The fix is simply to move the assert until after the write that satisifes the read.
src/libraries/System.IO.Pipes/tests/PipeStreamConformanceTests.cs