-
Notifications
You must be signed in to change notification settings - Fork 14
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
Abort pending tasks with ObjectDisposedException #4045
Conversation
@@ -32,13 +35,20 @@ internal sealed class TcpListener : IListener<IDuplexConnection> | |||
} | |||
catch (SocketException exception) | |||
{ | |||
if (exception.SocketErrorCode == SocketError.OperationAborted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated Tcp/Coloc listeners to do the same. Alternatively we can move this to Slic and don't update Tcp/Coloc behavior.
@@ -21,7 +21,7 @@ public async Task Ssl_client_connection_connect_fails_when_server_provides_untru | |||
.AddSingleton( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes required to build conformance tests with .NET9
[Test] | ||
[Ignore("TODO: Fix https://github.com/icerpc/icerpc-csharp/issues/3990")] | ||
public async Task Connection_dispose_aborts_pending_operations_with_operation_aborted_error() | ||
public async Task Connection_dispose_aborts_pending_operations_with_object_disposed_exception() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just test the new behavior with .NET 9 and greater.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised there is no change to the Ice/IceRpc ProtocolConnection code that calls these transport APIs.
Even if this code already handles ObjectDisposedException / IceRpcError.OperationAborted the same way, it would make sense to remove the OperationAborted handling from IceProtocolConnection (since no QUIC/Slic for the ice protocol) and add a comment to the IceRpcProtocolConnection code (keep OperationAborted for .NET 8 QUIC support?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
I have updated the server code to expect an Regarding the Lastly, the |
Do you mean it cancels the CTS they use and then waits for these tasks to complete before disposing the connection? |
src/IceRpc/Server.cs
Outdated
// The AcceptAsync call can fail with OperationAborted during shutdown if it is accepting a connection while the | ||
// listener is disposed. | ||
(exception is IceRpcException rpcException && rpcException.IceRpcError != IceRpcError.OperationAborted) || | ||
(exception is IceRpcException rpcException) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify - maybe exception is IceRpcException or AuthenticationException
?
catch (ObjectDisposedException) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
throw; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This additional fix is to ensure QUIC and Slic behave the same. CreateStreamAsync throw OperationCanceledException if ODE is received and task is already canceled.
I think there was a difference here with Slic and QUIC in CreateStreamAsync. If you cancel the cancellation token passed to CreateStreamAsync and then dispose the connection. Slic throws OperationCancelledException, Quic throws ObjectDisposedException, I fixed Quic connection to behave as Slic adding:
|
Fix #3990
.NET 9 updated QUIC implementation to cancel pending task with ODE, when the listener or connection are disposed. This PR updates the failing tests and align Slic with the new QUIC behavior.