Skip to content

Commit

Permalink
Make sure to release connection lock (#11049)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelm12 authored Jun 10, 2019
1 parent f76be64 commit ecd709e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1942,12 +1942,14 @@ public bool TryAcquireConnectionLock()
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<ConnectionState> 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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ async IAsyncEnumerable<string> clientStreamData()
}

[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)
Expand Down

0 comments on commit ecd709e

Please sign in to comment.