private unsafe int HandleEventShutdownComplete(ref SHUTDOWN_COMPLETE data) { if (data.ConnectionShutdown != 0) { bool shutdownByApp = data.ConnectionShutdownByApp != 0; bool closedRemotely = data.ConnectionClosedRemotely != 0; Exception exception = (shutdownByApp, closedRemotely) switch { // It's remote shutdown by app, peer's side called QuicConnection.CloseAsync, throw QuicError.ConnectionAborted. (shutdownByApp: true, closedRemotely : true) => ThrowHelper.GetConnectionAbortedException((long)data.ConnectionErrorCode), // It's local shutdown by app, this side called QuicConnection.CloseAsync, throw QuicError.OperationAborted. (shutdownByApp : true, closedRemotely : false) => ThrowHelper.GetOperationAbortedException(), // It's remote shutdown by transport, we received a CONNECTION_CLOSE frame with a QUIC transport error code // TODO: we should propagate the transport error code // https://github.com/dotnet/runtime/issues/72666 (shutdownByApp : false, closedRemotely : true) => ThrowHelper.GetExceptionForMsQuicStatus(data.ConnectionCloseStatus, $"Shutdown by transport {data.ConnectionErrorCode}"), // It's local shutdown by transport, due to some timeout // TODO: we should propagate transport error code // https://github.com/dotnet/runtime/issues/72666 (shutdownByApp : false, closedRemotely : false) => ThrowHelper.GetExceptionForMsQuicStatus(data.ConnectionCloseStatus), }; _startedTcs.TrySetException(exception); _receiveTcs.TrySetException(exception, final: true); _sendTcs.TrySetException(exception, final: true); }
private unsafe int HandleEventShutdownComplete(ref SHUTDOWN_COMPLETE data) { if (data.ConnectionShutdown != 0) { Exception exception = ThrowHelper.GetConnectionAbortedException(_connectionState.AbortErrorCode); _startedTcs.TrySetException(exception); _receiveTcs.TrySetException(exception, final: true); _sendTcs.TrySetException(exception, final: true); } _shutdownTcs.TrySetResult(); return(QUIC_STATUS_SUCCESS); }