[QUIC] Merge 7.0 fix (#90228)
authorMarie Píchová <11718369+ManickaP@users.noreply.github.com>
Mon, 14 Aug 2023 07:19:10 +0000 (09:19 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Aug 2023 07:19:10 +0000 (09:19 +0200)
* Merge pull request #90173 from vseanreesermsft/internal-merge-7.0-2023-08-08-1042

Merging internal commits for release/7.0

* Consume MsQuic release package on Win

---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
Co-authored-by: Natalia Kondratyeva <knatalia@microsoft.com>
eng/Versions.props
src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs
src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.cs
src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs
src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs

index b029396062b308f11aa677d3f94f1773ea6ed36a..72913567f0704337d40c5dca11606b826d59636c 100644 (file)
     <!-- ICU -->
     <MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-rc.1.23407.2</MicrosoftNETCoreRuntimeICUTransportVersion>
     <!-- MsQuic -->
-    <MicrosoftNativeQuicMsQuicVersion>2.1.7</MicrosoftNativeQuicMsQuicVersion>
+    <MicrosoftNativeQuicMsQuicVersion>2.2.2</MicrosoftNativeQuicMsQuicVersion>
     <SystemNetMsQuicTransportVersion>8.0.0-alpha.1.23180.2</SystemNetMsQuicTransportVersion>
     <!-- Mono LLVM -->
     <runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>16.0.5-alpha.1.23408.1</runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
index 281657f4ba5c0935ecbeafb2cd365e1d9a4a3341..ba05cef37b57573862acaba57f34f81abe0d3bc8 100644 (file)
@@ -14,7 +14,7 @@
     <ApiExclusionListPath Condition="'$(TargetPlatformIdentifier)' == ''">ExcludeApiList.PNSE.txt</ApiExclusionListPath>
     <!-- This controls if we consume official binaries from MsQuic or if we use binaries published from dotnet/msquic repo.
          Release branches should generally consume MsQuic release code, transport allows us to consume and test pre-released versions -->
-    <UseQuicTransportPackage  Condition="'$(UseQuicTransportPackage)' == ''">true</UseQuicTransportPackage>
+    <UseQuicTransportPackage  Condition="'$(UseQuicTransportPackage)' == ''">false</UseQuicTransportPackage>
   </PropertyGroup>
   <ItemGroup>
     <AssemblyAttribute Include="System.Runtime.Versioning.RequiresPreviewFeaturesAttribute" />
index 193a3db833c146090353649164fa465a13d1ba12..e07a99b13f7c70358ced0c1c21b76bea84f2e4e1 100644 (file)
@@ -18,7 +18,7 @@ internal sealed unsafe partial class MsQuicApi
 {
     private static readonly Version s_minWindowsVersion = new Version(10, 0, 20145, 1000);
 
-    private static readonly Version s_minMsQuicVersion = new Version(2, 1);
+    private static readonly Version s_minMsQuicVersion = new Version(2, 2, 2);
 
     private static readonly delegate* unmanaged[Cdecl]<uint, QUIC_API_TABLE**, int> MsQuicOpenVersion;
     private static readonly delegate* unmanaged[Cdecl]<QUIC_API_TABLE*, void> MsQuicClose;
index 732de3527499c645988bb5a37b7e3d77b1a02d9a..2fb9196ae707ad10c0ce31b8ed2f4d7c9df0643f 100644 (file)
@@ -151,6 +151,7 @@ namespace Microsoft.Quic
         NONE = 0x0000,
         UNIDIRECTIONAL = 0x0001,
         ZERO_RTT = 0x0002,
+        DELAY_FC_UPDATES = 0x0004,
     }
 
     [System.Flags]
index a25ce5b9e4f787087fde0d13dae053b115e79546..a2ade033afe59f5a20ff94b439489ec42d3649da 100644 (file)
@@ -515,6 +515,7 @@ public sealed partial class QuicConnection : IAsyncDisposable
             return QUIC_STATUS_SUCCESS;
         }
 
+        data.Flags |= QUIC_STREAM_OPEN_FLAGS.DELAY_FC_UPDATES;
         return QUIC_STATUS_SUCCESS;
     }
     private unsafe int HandleEventPeerCertificateReceived(ref PEER_CERTIFICATE_RECEIVED_DATA data)
index 2b18c8405569225f440cdda80e222fc0b5d3824a..503c2d4068355dde268022b33757b008eadb0343 100644 (file)
@@ -709,6 +709,32 @@ namespace System.Net.Quic.Tests
             await serverConnection.DisposeAsync();
         }
 
+        [Fact]
+        public async Task OpenStreamAsync_BlocksUntilAvailable_PeerClosesWritingUnidirectional()
+        {
+            QuicListenerOptions listenerOptions = new QuicListenerOptions()
+            {
+                ListenEndPoint = new IPEndPoint(IPAddress.Loopback, 0),
+                ApplicationProtocols = new List<SslApplicationProtocol>() { ApplicationProtocol },
+                ConnectionOptionsCallback = (_, _, _) =>
+                {
+                    var serverOptions = CreateQuicServerOptions();
+                    serverOptions.MaxInboundBidirectionalStreams = 1;
+                    serverOptions.MaxInboundUnidirectionalStreams = 1;
+                    return ValueTask.FromResult(serverOptions);
+                }
+            };
+            (QuicConnection clientConnection, QuicConnection serverConnection) = await CreateConnectedQuicConnection(null, listenerOptions);
+
+            // Open one stream, second call should block
+            await using var stream = await clientConnection.OpenOutboundStreamAsync(QuicStreamType.Unidirectional);
+            await stream.WriteAsync(new byte[64*1024], completeWrites: true);
+            await Assert.ThrowsAsync<TimeoutException>(() => clientConnection.OpenOutboundStreamAsync(QuicStreamType.Unidirectional).AsTask().WaitAsync(TimeSpan.FromSeconds(1)));
+
+            await clientConnection.DisposeAsync();
+            await serverConnection.DisposeAsync();
+        }
+
         [Theory]
         [InlineData(false)]
         [InlineData(true)]
@@ -747,11 +773,24 @@ namespace System.Net.Quic.Tests
 
             // Close the streams, the waitTask should finish as a result.
             await stream.DisposeAsync();
-            QuicStream newStream = await serverConnection.AcceptInboundStreamAsync();
-            await newStream.DisposeAsync();
+            // Drain all server streams.
+            while (true)
+            {
+                using var acceptCts = new CancellationTokenSource(TimeSpan.FromSeconds(0.5));
+                try
+                {
+                    QuicStream serverStream = await serverConnection.AcceptInboundStreamAsync(acceptCts.Token);
+                    await serverStream.DisposeAsync();
+                }
+                catch (OperationCanceledException)
+                {
+                    // Token expired, no more streams in the server queue, exit the loop.
+                    break;
+                }
+            }
 
             // next call should work as intended
-            newStream = await OpenStreamAsync(clientConnection).AsTask().WaitAsync(TimeSpan.FromSeconds(10));
+            var newStream = await OpenStreamAsync(clientConnection).AsTask().WaitAsync(TimeSpan.FromSeconds(10));
             await newStream.DisposeAsync();
 
             await clientConnection.DisposeAsync();