From cb3a84c71786a316926e90323481fedb97fd35a9 Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Thu, 6 Jun 2024 23:06:01 +0200 Subject: [PATCH 1/6] Ensure RemoteInvokeHandle is disposed --- .../tests/FunctionalTests/SocketDuplicationTests.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs index a9cb168de3eccf..b8e8b290651cce 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs @@ -330,8 +330,16 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily else { RemoteInvokeHandle hServerProc = RemoteExecutor.Invoke(HandlerServerCode, _ipcPipeName); - await RunCommonHostLogic(hServerProc.Process.Id); - await hServerProc.DisposeAsync(); + + // Since RunCommonHostLogic can throw, we need to make sure the server process is disposed + try + { + await RunCommonHostLogic(hServerProc.Process.Id); + } + finally + { + await hServerProc.DisposeAsync(); + } } async Task RunCommonHostLogic(int processId) From 0d7279593e5f26689b5a96228523f707d45bc9ce Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Thu, 6 Jun 2024 23:07:11 +0200 Subject: [PATCH 2/6] Make RunCommonHostLogic synchronous --- .../System.Net.Sockets/System.Net.Sockets.sln | 26 ++++++++++++------- .../FunctionalTests/SocketDuplicationTests.cs | 8 +++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln index edac3bf4a63f18..8ca2a3b13e79d6 100644 --- a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln +++ b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln @@ -1,4 +1,8 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34928.147 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamConformanceTests", "..\Common\tests\StreamConformanceTests\StreamConformanceTests.csproj", "{E5699508-7F83-4125-9495-C73BD4C43046}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{AEDCC778-C0D1-4155-9DD2-45EBF160CDA0}" @@ -43,11 +47,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7108F0-035 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{51E336C9-CFE7-4459-B407-FD5D9E760D85}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "tools\gen", "{CCBA19A8-17AB-402A-96E6-A1C92784EAC2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{CCBA19A8-17AB-402A-96E6-A1C92784EAC2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "tools\src", "{99B1FC8E-726F-4DBF-887D-38AC7F63C230}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{99B1FC8E-726F-4DBF-887D-38AC7F63C230}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "tools\ref", "{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{725DA203-1DB5-47D5-991A-8440E254BB23}" EndProject @@ -136,27 +140,31 @@ Global GlobalSection(NestedProjects) = preSolution {E5699508-7F83-4125-9495-C73BD4C43046} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} {AEDCC778-C0D1-4155-9DD2-45EBF160CDA0} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} - {69A7DCCE-B05B-44F3-B7BC-17A90759D1A2} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} {3C5413D5-7662-4E7C-8A1D-C8E6C527782F} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {5BE2193A-9EAB-4F1C-B2F4-E969C84F2614} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {EAEEEA1F-FE18-4CA1-88C9-59CD1097C593} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FDFDE647-E25F-4B21-B002-4EEEFC42EFA1} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} - {293F6DBE-2ECA-4F22-AF58-4AC1668F028B} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} - {F7A848B6-8307-4702-AEEE-20223FB73F29} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FD313302-FE04-414E-8A62-3BC8894115C1} = {2C7108F0-035E-44A5-8451-FE9535F53D43} + {69A7DCCE-B05B-44F3-B7BC-17A90759D1A2} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} {85782EDD-90A7-4600-89EB-4E2C0AAAD446} = {51E336C9-CFE7-4459-B407-FD5D9E760D85} {0CAE4AA4-2C81-4CA4-978A-F86DD25FA338} = {51E336C9-CFE7-4459-B407-FD5D9E760D85} {3DD27643-568B-4BA1-82F2-FACFC8365836} = {51E336C9-CFE7-4459-B407-FD5D9E760D85} + {293F6DBE-2ECA-4F22-AF58-4AC1668F028B} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} + {F7A848B6-8307-4702-AEEE-20223FB73F29} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FA256A4B-476D-4BCA-8E62-C2A11DF778CE} = {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} {6D7B425E-F07B-4572-98D8-728E3053E30F} = {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} - {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} = {725DA203-1DB5-47D5-991A-8440E254BB23} {21411575-DD1A-45E1-8B10-6D4EA58684CD} = {99B1FC8E-726F-4DBF-887D-38AC7F63C230} {FA935CE3-6C83-4993-B565-95DF3129A43B} = {99B1FC8E-726F-4DBF-887D-38AC7F63C230} - {99B1FC8E-726F-4DBF-887D-38AC7F63C230} = {725DA203-1DB5-47D5-991A-8440E254BB23} {C2011D8C-93D7-486E-8B01-0792262F4EF8} = {2D08A54A-C557-444C-9D8D-0BF0E20CDE5A} + {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} = {725DA203-1DB5-47D5-991A-8440E254BB23} + {99B1FC8E-726F-4DBF-887D-38AC7F63C230} = {725DA203-1DB5-47D5-991A-8440E254BB23} {2D08A54A-C557-444C-9D8D-0BF0E20CDE5A} = {725DA203-1DB5-47D5-991A-8440E254BB23} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BA222465-FBD4-4377-8A8A-783BF85E01F7} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{6d7b425e-f07b-4572-98d8-728e3053e30f}*SharedItemsImports = 5 + ..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{fa935ce3-6c83-4993-b565-95df3129a43b}*SharedItemsImports = 5 + EndGlobalSection EndGlobal diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs index b8e8b290651cce..562f6dc0d8466a 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs @@ -324,7 +324,7 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily if (sameProcess) { Task handlerCode = Task.Run(() => HandlerServerCode(_ipcPipeName)); - await RunCommonHostLogic(Environment.ProcessId); + RunCommonHostLogic(Environment.ProcessId); await handlerCode; } else @@ -334,7 +334,7 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily // Since RunCommonHostLogic can throw, we need to make sure the server process is disposed try { - await RunCommonHostLogic(hServerProc.Process.Id); + RunCommonHostLogic(hServerProc.Process.Id); } finally { @@ -342,10 +342,8 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily } } - async Task RunCommonHostLogic(int processId) + void RunCommonHostLogic(int processId) { - await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); - pipeServerStream.WaitForConnection(); // Duplicate the socket: From babfa61e6b4f86f1461edd9e3d28cc4849cc12e2 Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Thu, 6 Jun 2024 23:17:01 +0200 Subject: [PATCH 3/6] Document DisposeAsync intent. --- .../tests/System/Net/RemoteExecutorExtensions.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libraries/Common/tests/System/Net/RemoteExecutorExtensions.cs b/src/libraries/Common/tests/System/Net/RemoteExecutorExtensions.cs index 48ecfed7939ac7..ae1c0f2d9ab366 100644 --- a/src/libraries/Common/tests/System/Net/RemoteExecutorExtensions.cs +++ b/src/libraries/Common/tests/System/Net/RemoteExecutorExtensions.cs @@ -8,6 +8,17 @@ namespace Microsoft.DotNet.RemoteExecutor; internal static class RemoteExecutorExtensions { + /// + /// Dispose the RemoteInvokeHandle synchronously can take considerable time, and cause other unrelated tests to fail on timeout + /// because of depletion of xUnit synchronization context threads. + /// Running dispose in a separate task on the thread pool can help alleviate this issue. + /// + /// + /// Executes the ServerCode in separate process and awaits its completion in a separate task outside of current synchronization context. + /// + /// await RemoteExecutor.Invoke(ServerCode).DisposeAsync(); + /// + /// public static async ValueTask DisposeAsync(this RemoteInvokeHandle handle) { await Task.Run(handle.Dispose); From 922d4be1d78db218d19b5ab9072b3ab99be91398 Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Fri, 7 Jun 2024 14:46:13 +0200 Subject: [PATCH 4/6] Repalce namedpipe IPC by Socket IPC --- .../FunctionalTests/SocketDuplicationTests.cs | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs index 562f6dc0d8466a..8d2e237a3497e7 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Globalization; using System.IO; using System.IO.Pipes; using System.Runtime.Serialization.Formatters.Binary; @@ -265,7 +266,6 @@ public void SocketCtr_SocketInformation_WhenProtocolInformationTooShort_Throws() public abstract class PolymorphicTests where T : SocketHelperBase, new() { private static readonly T Helper = new T(); - private readonly string _ipcPipeName = Path.GetRandomFileName(); private static void WriteSocketInfo(Stream stream, SocketInformation socketInfo) { @@ -317,19 +317,21 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily // Async is allowed on the listener: using Socket handlerOriginal = await listener.AcceptAsync(); - // pipe used to exchange socket info - await using NamedPipeServerStream pipeServerStream = - new NamedPipeServerStream(_ipcPipeName, PipeDirection.Out); + // socket used to exchange duplicated socket info with server code + using Socket ipcServerListener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + ipcServerListener.BindToAnonymousPort(IPAddress.Loopback); + ipcServerListener.Listen(1); + string ipcPortString = ((IPEndPoint)ipcServerListener.LocalEndPoint).Port.ToString(CultureInfo.InvariantCulture); if (sameProcess) { - Task handlerCode = Task.Run(() => HandlerServerCode(_ipcPipeName)); + Task handlerCode = Task.Run(() => HandlerServerCode(ipcPortString)); RunCommonHostLogic(Environment.ProcessId); await handlerCode; } else { - RemoteInvokeHandle hServerProc = RemoteExecutor.Invoke(HandlerServerCode, _ipcPipeName); + RemoteInvokeHandle hServerProc = RemoteExecutor.Invoke(HandlerServerCode, ipcPortString); // Since RunCommonHostLogic can throw, we need to make sure the server process is disposed try @@ -344,23 +346,27 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily void RunCommonHostLogic(int processId) { - pipeServerStream.WaitForConnection(); + using Socket ipcServer = ipcServerListener.Accept(); // Duplicate the socket: SocketInformation socketInfo = handlerOriginal.DuplicateAndClose(processId); - WriteSocketInfo(pipeServerStream, socketInfo); + // Send socketInfo to server code + using var ipcStream = new NetworkStream(ipcServer, false); + WriteSocketInfo(new NetworkStream(ipcServer), socketInfo); // Send client data: client.Send(TestBytes); } - static async Task HandlerServerCode(string ipcPipeName) + static async Task HandlerServerCode(string ipcPortString) { - await using NamedPipeClientStream pipeClientStream = - new NamedPipeClientStream(".", ipcPipeName, PipeDirection.In); - pipeClientStream.Connect(); + int ipcPort = int.Parse(ipcPortString, CultureInfo.InvariantCulture); + using Socket ipcClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + await ipcClient.ConnectAsync(IPAddress.Loopback, ipcPort); + + await using var ipcStream = new NetworkStream(ipcClient, true); + SocketInformation socketInfo = ReadSocketInfo(ipcStream); - SocketInformation socketInfo = ReadSocketInfo(pipeClientStream); using Socket handler = new Socket(socketInfo); Assert.True(handler.IsBound); From 666c5db454b2d9f6c6999aab960fb144467c6dc8 Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Fri, 7 Jun 2024 14:47:26 +0200 Subject: [PATCH 5/6] Revert .sln --- .../System.Net.Sockets/System.Net.Sockets.sln | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln index 8ca2a3b13e79d6..edac3bf4a63f18 100644 --- a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln +++ b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln @@ -1,8 +1,4 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.10.34928.147 -MinimumVisualStudioVersion = 10.0.40219.1 +Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamConformanceTests", "..\Common\tests\StreamConformanceTests\StreamConformanceTests.csproj", "{E5699508-7F83-4125-9495-C73BD4C43046}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{AEDCC778-C0D1-4155-9DD2-45EBF160CDA0}" @@ -47,11 +43,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7108F0-035 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{51E336C9-CFE7-4459-B407-FD5D9E760D85}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{CCBA19A8-17AB-402A-96E6-A1C92784EAC2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "tools\gen", "{CCBA19A8-17AB-402A-96E6-A1C92784EAC2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{99B1FC8E-726F-4DBF-887D-38AC7F63C230}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "tools\src", "{99B1FC8E-726F-4DBF-887D-38AC7F63C230}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "tools\ref", "{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{725DA203-1DB5-47D5-991A-8440E254BB23}" EndProject @@ -140,31 +136,27 @@ Global GlobalSection(NestedProjects) = preSolution {E5699508-7F83-4125-9495-C73BD4C43046} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} {AEDCC778-C0D1-4155-9DD2-45EBF160CDA0} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} + {69A7DCCE-B05B-44F3-B7BC-17A90759D1A2} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} {3C5413D5-7662-4E7C-8A1D-C8E6C527782F} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {5BE2193A-9EAB-4F1C-B2F4-E969C84F2614} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {EAEEEA1F-FE18-4CA1-88C9-59CD1097C593} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FDFDE647-E25F-4B21-B002-4EEEFC42EFA1} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} + {293F6DBE-2ECA-4F22-AF58-4AC1668F028B} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} + {F7A848B6-8307-4702-AEEE-20223FB73F29} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FD313302-FE04-414E-8A62-3BC8894115C1} = {2C7108F0-035E-44A5-8451-FE9535F53D43} - {69A7DCCE-B05B-44F3-B7BC-17A90759D1A2} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82} {85782EDD-90A7-4600-89EB-4E2C0AAAD446} = {51E336C9-CFE7-4459-B407-FD5D9E760D85} {0CAE4AA4-2C81-4CA4-978A-F86DD25FA338} = {51E336C9-CFE7-4459-B407-FD5D9E760D85} {3DD27643-568B-4BA1-82F2-FACFC8365836} = {51E336C9-CFE7-4459-B407-FD5D9E760D85} - {293F6DBE-2ECA-4F22-AF58-4AC1668F028B} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} - {F7A848B6-8307-4702-AEEE-20223FB73F29} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF} {FA256A4B-476D-4BCA-8E62-C2A11DF778CE} = {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} {6D7B425E-F07B-4572-98D8-728E3053E30F} = {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} + {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} = {725DA203-1DB5-47D5-991A-8440E254BB23} {21411575-DD1A-45E1-8B10-6D4EA58684CD} = {99B1FC8E-726F-4DBF-887D-38AC7F63C230} {FA935CE3-6C83-4993-B565-95DF3129A43B} = {99B1FC8E-726F-4DBF-887D-38AC7F63C230} - {C2011D8C-93D7-486E-8B01-0792262F4EF8} = {2D08A54A-C557-444C-9D8D-0BF0E20CDE5A} - {CCBA19A8-17AB-402A-96E6-A1C92784EAC2} = {725DA203-1DB5-47D5-991A-8440E254BB23} {99B1FC8E-726F-4DBF-887D-38AC7F63C230} = {725DA203-1DB5-47D5-991A-8440E254BB23} + {C2011D8C-93D7-486E-8B01-0792262F4EF8} = {2D08A54A-C557-444C-9D8D-0BF0E20CDE5A} {2D08A54A-C557-444C-9D8D-0BF0E20CDE5A} = {725DA203-1DB5-47D5-991A-8440E254BB23} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BA222465-FBD4-4377-8A8A-783BF85E01F7} EndGlobalSection - GlobalSection(SharedMSBuildProjectFiles) = preSolution - ..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{6d7b425e-f07b-4572-98d8-728e3053e30f}*SharedItemsImports = 5 - ..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{fa935ce3-6c83-4993-b565-95df3129a43b}*SharedItemsImports = 5 - EndGlobalSection EndGlobal From e61fd715aea34d94f029e6a4254dd985af212937 Mon Sep 17 00:00:00 2001 From: Roman Konecny Date: Sun, 9 Jun 2024 23:31:15 +0200 Subject: [PATCH 6/6] Setting NoDelay for ipc sockets --- .../tests/FunctionalTests/SocketDuplicationTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs index 8d2e237a3497e7..4ff0052bffb06a 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs @@ -347,6 +347,7 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily void RunCommonHostLogic(int processId) { using Socket ipcServer = ipcServerListener.Accept(); + ipcServer.NoDelay = true; // Duplicate the socket: SocketInformation socketInfo = handlerOriginal.DuplicateAndClose(processId); @@ -362,6 +363,7 @@ static async Task HandlerServerCode(string ipcPortString) { int ipcPort = int.Parse(ipcPortString, CultureInfo.InvariantCulture); using Socket ipcClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + ipcClient.NoDelay = true; await ipcClient.ConnectAsync(IPAddress.Loopback, ipcPort); await using var ipcStream = new NetworkStream(ipcClient, true);