From 3d1f86d1d312886ee1de4b11387aaa7a3a5e296d Mon Sep 17 00:00:00 2001 From: wfurt Date: Fri, 1 Mar 2024 15:36:30 -0800 Subject: [PATCH] make Socket useable after cancellation --- .../src/System/Net/Sockets/Socket.cs | 2 +- .../FunctionalTests/NetworkStreamTest.cs | 73 ++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs index a8c95005154c9..070848031a003 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs @@ -3754,7 +3754,7 @@ internal void UpdateStatusAfterSocketError(SocketError errorCode, bool disconnec if (disconnectOnFailure && _isConnected && (_handle.IsInvalid || (errorCode != SocketError.WouldBlock && errorCode != SocketError.IOPending && errorCode != SocketError.NoBufferSpaceAvailable && - errorCode != SocketError.TimedOut))) + errorCode != SocketError.TimedOut && errorCode != SocketError.OperationAborted))) { // The socket is no longer a valid socket. if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, "Invalidating socket."); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.cs index 52022c5da8216..a2df38adac5db 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.cs @@ -547,7 +547,7 @@ private static async Task RunWithConnectedNetworkStreamsAsync(Func