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

Fixed icerpc protocol connection shutdown #2289

Merged
merged 3 commits into from
Dec 14, 2022

Conversation

bentoi
Copy link
Contributor

@bentoi bentoi commented Dec 13, 2022

This PR fixes the IceRpc protocol connection shutdown to ignore failures from the CloseAsync call due to a potential transportConnection.DisposeAsync() call.

{
throw new IceRpcException(IceRpcError.OperationAborted, exception);
// Expected if the peer closed the connection first and AcceptStreamAsync closed the connection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the comment and the code ultra confusing:

  • AcceptStreamAsync is a method on the transport connection. Why would it close the connection??
  • Having TransportConnection.CloseAsync and CloseAsync with totally different semantics (CloseAsync calls _transportConnection.DisposeAsync, not CloseAsync) is not helpful

Copy link
Contributor Author

@bentoi bentoi Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the comment to:

// Expected if the peer closed the connection first and the accept request task closed the connection.

Having TransportConnection.CloseAsync and CloseAsync with totally different semantics (CloseAsync calls _transportConnection.DisposeAsync, not CloseAsync) is not helpful.

Ok, I give up 🙂.

Is the following OK?

/// <summary>Marks the protocol connection as closed, disposes the transport connection and cancels 
/// pending dispatches and invocations.</summary>
private async Task DisposeTransportAsync(string? message = null, Exception? exception = null)

@bentoi bentoi marked this pull request as ready for review December 13, 2022 18:16
}
catch (ObjectDisposedException)
{
// Expected if the peer closed the connection first and the accept request task closed the connection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really: the accept requests loop disposed the transport connection.

{
throw new IceRpcException(IceRpcError.OperationAborted, exception);
// Expected if the peer closed the connection first and the accept request task closed the connection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really: the "accept requests loop" (or accept requests task) disposed the transport connection while this CloseAsync was in progress.

And presumably, transportConnection.DisposeAsync does not wait for an outstanding CloseAsync to complete: it aborts it. Is this the correct semantics for multiplexed connection?

See also dotnet/runtime#78641 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment here #2225 (comment)

@bentoi bentoi merged commit b83d3d9 into icerpc:main Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants