Skip to content

Commit 5a43d62

Browse files
TcpReceiveSendGetsCanceledByDispose: update test for change in Linux kernel. (#93502)
Co-authored-by: Tom Deseyn <tom.deseyn@gmail.com>
1 parent 324f912 commit 5a43d62

File tree

1 file changed

+6
-5
lines changed
  • src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive

1 file changed

+6
-5
lines changed

src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1019,11 +1019,12 @@ public async Task TcpReceiveSendGetsCanceledByDispose(bool receiveOrSend, bool i
10191019
return;
10201020
}
10211021

1022-
// RHEL7 kernel has a bug preventing close(AF_UNKNOWN) to succeed with IPv6 sockets.
1023-
// In this case Dispose will trigger a graceful shutdown, which means that receive will succeed on socket2.
1024-
// This bug is fixed in kernel 3.10.0-1160.25+.
1025-
// TODO: Remove this, once CI machines are updated to a newer kernel.
1026-
bool mayShutdownGraceful = UsesSync && PlatformDetection.IsRedHatFamily7 && receiveOrSend && (ipv6Server || dualModeClient);
1022+
// .NET uses connect(AF_UNSPEC) to abort on-going operations on Linux.
1023+
// Linux 6.4+ introduced a change (4faeee0cf8a5d88d63cdbc3bab124fb0e6aed08c) which disallows
1024+
// this operation while operations are on-going.
1025+
// When the connect fails, .NET falls back to use shutdown(SHUT_RDWR).
1026+
// This causes the receive on socket2 to succeed instead of failing with ConnectionReset.
1027+
bool mayShutdownGraceful = UsesSync && PlatformDetection.IsLinux && receiveOrSend;
10271028

10281029
// We try this a couple of times to deal with a timing race: if the Dispose happens
10291030
// before the operation is started, the peer won't see a ConnectionReset SocketException and we won't

0 commit comments

Comments
 (0)