Change lifetime of Socket used in NamedPipeServerStream on Unix
authorStephen Toub <stoub@microsoft.com>
Sun, 22 Oct 2017 13:23:52 +0000 (09:23 -0400)
committerStephen Toub <stoub@microsoft.com>
Tue, 31 Oct 2017 16:03:02 +0000 (12:03 -0400)
commitc559bc1325ab6beb48e52d09975ffae33e0316f4
treefe39108c34c7a3ee9a406cb55d92503a12d430c8
parenta98f3dec545c838c096479d84086fab3f93810cb
Change lifetime of Socket used in NamedPipeServerStream on Unix

We currently create and destroy the unix domain socket each time WaitForConnection{Async} is called, and it lives until the client connects.  This causes problems when multiple clients try to connect before WaitForConnection{Async} is called; any number that's under the min listen limit applied by the OS will have their connections completed, even though Accept hasn't been called, and then when the socket is closed, the connections will all fail.  This change moves the UDS creation to when the NamedPipeServerStream is created, deleting it when the NPSS is disposed.

Commit migrated from https://github.com/dotnet/corefx/commit/16b29a8ca2f075edfb27a720782320e720bb8941
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Unix.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Windows.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.cs
src/libraries/System.IO.Pipes/tests/NamedPipeTests/NamedPipeTest.Specific.cs