From 5ca997055c8a70dfe819165a42ce353d7fed20a5 Mon Sep 17 00:00:00 2001 From: Alexander Nikolaev Date: Fri, 16 Jul 2021 15:06:11 +0200 Subject: [PATCH] Fix Http2Connection.GetIdleTicks --- .../Net/Http/SocketsHttpHandler/Http2Connection.cs | 2 +- .../tests/FunctionalTests/SocketsHttpHandlerTest.cs | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index 26058a454a9e17..11d4d9ce5bb9af 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -1697,7 +1697,7 @@ public override long GetIdleTicks(long nowTicks) { lock (SyncObject) { - return _streamsInUse == 0 ? _idleSinceTickCount - nowTicks : 0; + return _streamsInUse == 0 ? nowTicks - _idleSinceTickCount : 0; } } diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs index b326c8bbb02146..b5988fafed3036 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs @@ -2214,7 +2214,6 @@ public async Task Http2_MultipleConnectionsEnabled_OpenAndCloseMultipleConnectio [ConditionalFact(nameof(SupportsAlpn))] [OuterLoop("Incurs long delay")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/43877")] public async Task Http2_MultipleConnectionsEnabled_IdleConnectionTimeoutExpired_ConnectionRemovedAndNewCreated() { const int MaxConcurrentStreams = 2; @@ -2244,15 +2243,6 @@ public async Task Http2_MultipleConnectionsEnabled_IdleConnectionTimeoutExpired_ // Wait until the idle connection timeout expires. await connection1.WaitForClientDisconnectAsync(false).WaitAsync(TestHelper.PassingTestTimeout).ConfigureAwait(false); - // Client connection might be still alive, so send an extra request which will either land on the shutting down connection or on a new one. - try - { - await client.GetAsync(server.Address).WaitAsync(handler.PooledConnectionIdleTimeout).ConfigureAwait(false); - } - catch (Exception) - { - // Suppress all exceptions. - } Assert.True(connection1.IsInvalid); Assert.False(connection0.IsInvalid);