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

Update MsQuic and use ConnectionCloseStatus in StreamShutdown #73563

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed unsafe class MsQuicApi
{
private static readonly Version MinWindowsVersion = new Version(10, 0, 20145, 1000);

private static readonly Version MsQuicVersion = new Version(2, 0);
private static readonly Version MsQuicVersion = new Version(2, 1);

public MsQuicSafeHandle Registration { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ internal enum QUIC_CREDENTIAL_FLAGS
USE_SYSTEM_MAPPER = 0x00010000,
CACHE_ONLY_URL_RETRIEVAL = 0x00020000,
REVOCATION_CHECK_CACHE_ONLY = 0x00040000,
INPROC_PEER_CERTIFICATE = 0x00080000,
}

[System.Flags]
Expand Down Expand Up @@ -424,6 +425,7 @@ internal enum QUIC_CIPHER_SUITE
internal enum QUIC_CONGESTION_CONTROL_ALGORITHM
{
CUBIC,
BBR,
MAX,
}

Expand Down Expand Up @@ -2481,6 +2483,9 @@ internal byte RESERVED

[NativeTypeName("QUIC_UINT62")]
internal ulong ConnectionErrorCode;

[NativeTypeName("HRESULT")]
internal int ConnectionCloseStatus;
}

internal partial struct _IDEAL_SEND_BUFFER_SIZE_e__Struct
Expand Down Expand Up @@ -2782,6 +2787,9 @@ internal static unsafe partial class MsQuic
[NativeTypeName("#define QUIC_PARAM_STREAM_PRIORITY 0x08000003")]
internal const uint QUIC_PARAM_STREAM_PRIORITY = 0x08000003;

[NativeTypeName("#define QUIC_PARAM_STREAM_STATISTICS 0X08000004")]
internal const uint QUIC_PARAM_STREAM_STATISTICS = 0X08000004;

[NativeTypeName("#define QUIC_API_VERSION_2 2")]
internal const uint QUIC_API_VERSION_2 = 2;
}
Expand Down
10 changes: 6 additions & 4 deletions src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,14 @@ private unsafe int HandleEventShutdownComplete(ref SHUTDOWN_COMPLETE data)
(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, (TODO: we should propagate transport error code), throw QuicError.InternalError.
// 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(QUIC_STATUS_INTERNAL_ERROR, $"Shutdown by transport {data.ConnectionErrorCode}"),
// It's local shutdown by transport, assuming idle connection (TODO: we should get Connection.CloseStatus), throw QuicError.ConnectionIdle.
(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(QUIC_STATUS_CONNECTION_IDLE),
(shutdownByApp: false, closedRemotely: false) => ThrowHelper.GetExceptionForMsQuicStatus(data.ConnectionCloseStatus),
};
_startedTcs.TrySetException(exception);
_receiveTcs.TrySetException(exception, final: true);
Expand Down