Skip to content

Commit d1ca532

Browse files
TcpReceiveSendGetsCanceledByDispose: update test for change in Linux kernel. (#93505)
Co-authored-by: Tom Deseyn <tom.deseyn@gmail.com>
1 parent 69483a0 commit d1ca532

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

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

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,11 +1013,12 @@ public async Task TcpReceiveSendGetsCanceledByDispose(bool receiveOrSend, bool i
10131013
return;
10141014
}
10151015

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

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

0 commit comments

Comments
 (0)