diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index 0a8aaff9970bf3..053bc0a2feec22 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -1003,8 +1003,9 @@ public async Task TcpReceiveSendGetsCanceledByDispose(bool receiveOrSend, bool i { // RHEL7 kernel has a bug preventing close(AF_UNKNOWN) to succeed with IPv6 sockets. // In this case Dispose will trigger a graceful shutdown, which means that receive will succeed on socket2. + // This bug is fixed in kernel 3.10.0-1160.25+. // TODO: Remove this, once CI machines are updated to a newer kernel. - bool expectGracefulShutdown = UsesSync && PlatformDetection.IsRedHatFamily7 && receiveOrSend && (ipv6Server || dualModeClient); + bool mayShutdownGraceful = UsesSync && PlatformDetection.IsRedHatFamily7 && receiveOrSend && (ipv6Server || dualModeClient); // We try this a couple of times to deal with a timing race: if the Dispose happens // before the operation is started, the peer won't see a ConnectionReset SocketException and we won't @@ -1092,17 +1093,17 @@ await RetryHelper.ExecuteAsync(async () => } } - if (!expectGracefulShutdown) + try { Assert.Equal(SocketError.ConnectionReset, peerSocketError); } - else + catch when (mayShutdownGraceful) { Assert.Null(peerSocketError); } } } - }, maxAttempts: 10, retryWhen: e => e is XunitException); + }, maxAttempts: 8, retryWhen: e => e is XunitException); } [Fact]