Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock on connection close #476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/ArtemisNetClient/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,33 @@
}
}

public async ValueTask DisposeAsync()

Check warning on line 121 in src/ArtemisNetClient/Connection.cs

View workflow job for this annotation

GitHub Actions / windows

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 121 in src/ArtemisNetClient/Connection.cs

View workflow job for this annotation

GitHub Actions / windows

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 121 in src/ArtemisNetClient/Connection.cs

View workflow job for this annotation

GitHub Actions / windows

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 121 in src/ArtemisNetClient/Connection.cs

View workflow job for this annotation

GitHub Actions / windows

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 121 in src/ArtemisNetClient/Connection.cs

View workflow job for this annotation

GitHub Actions / linux

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
if (_disposed)
return;

if (!_closed)
{
await _connection.CloseAsync().ConfigureAwait(false);
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
try
{
_connection.AddClosedCallback((o, e) =>
{
if (e != null)
{
tcs.TrySetException(new AmqpException(e));
}
else
{
tcs.TrySetResult(null);
}
});
_ = _connection.CloseAsync().ConfigureAwait(false);
}
catch (Exception exception)
{
tcs.TrySetException(exception);
}
}

_disposed = true;
Expand Down
Loading