From ecd709eb9ab180f3c9a2d81dfde5e080c8d7d6b8 Mon Sep 17 00:00:00 2001 From: Mikael Mengistu Date: Mon, 10 Jun 2019 15:38:07 -0700 Subject: [PATCH] Make sure to release connection lock (#11049) --- src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs | 2 ++ .../csharp/Client/test/FunctionalTests/HubConnectionTests.cs | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs b/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs index 98524d6d9a..a36b69f842 100644 --- a/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs +++ b/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs @@ -1942,12 +1942,14 @@ namespace Microsoft.AspNetCore.SignalR.Client return _connectionLock.Wait(0); } + // Don't call this method in a try/finally that releases the lock since we're also potentially releasing the connection lock here. public async Task WaitForActiveConnectionAsync(string methodName, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0) { await WaitConnectionLockAsync(methodName); if (CurrentConnectionStateUnsynchronized == null || CurrentConnectionStateUnsynchronized.Stopping) { + ReleaseConnectionLock(methodName); throw new InvalidOperationException($"The '{methodName}' method cannot be called if the connection is not active"); } diff --git a/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs b/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs index de1170f1bb..82e95d78c2 100644 --- a/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs +++ b/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs @@ -770,7 +770,6 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests } [Theory] - [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2465", FlakyOn.All)] [MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))] [LogLevel(LogLevel.Trace)] public async Task CanCancelIAsyncEnumerableClientToServerUpload(string protocolName, HttpTransportType transportType, string path)