Skip to content

Commit

Permalink
Update MsQuic and use ConnectionCloseStatus in StreamShutdown (#73563)
Browse files Browse the repository at this point in the history
* Update MsQuic and use ConnectionCloseStatus in StreamShutdown

* Require MsQuic 2.1.*

* Add a few comments
  • Loading branch information
rzikm committed Aug 10, 2022
1 parent bbcc0ab commit 8a4de2e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
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 @@ -537,12 +537,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

0 comments on commit 8a4de2e

Please sign in to comment.