Skip to content

Commit 8986374

Browse files
ManickaPcarlossanlopCarnaViire
authored
[QUIC] Merge 7.0 fix (#90228)
* 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>
1 parent a19585d commit 8986374

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
<!-- ICU -->
218218
<MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-rc.1.23407.2</MicrosoftNETCoreRuntimeICUTransportVersion>
219219
<!-- MsQuic -->
220-
<MicrosoftNativeQuicMsQuicVersion>2.1.7</MicrosoftNativeQuicMsQuicVersion>
220+
<MicrosoftNativeQuicMsQuicVersion>2.2.2</MicrosoftNativeQuicMsQuicVersion>
221221
<SystemNetMsQuicTransportVersion>8.0.0-alpha.1.23180.2</SystemNetMsQuicTransportVersion>
222222
<!-- Mono LLVM -->
223223
<runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>16.0.5-alpha.1.23408.1</runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>

src/libraries/System.Net.Quic/src/System.Net.Quic.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<ApiExclusionListPath Condition="'$(TargetPlatformIdentifier)' == ''">ExcludeApiList.PNSE.txt</ApiExclusionListPath>
1515
<!-- This controls if we consume official binaries from MsQuic or if we use binaries published from dotnet/msquic repo.
1616
Release branches should generally consume MsQuic release code, transport allows us to consume and test pre-released versions -->
17-
<UseQuicTransportPackage Condition="'$(UseQuicTransportPackage)' == ''">true</UseQuicTransportPackage>
17+
<UseQuicTransportPackage Condition="'$(UseQuicTransportPackage)' == ''">false</UseQuicTransportPackage>
1818
</PropertyGroup>
1919
<ItemGroup>
2020
<AssemblyAttribute Include="System.Runtime.Versioning.RequiresPreviewFeaturesAttribute" />

src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal sealed unsafe partial class MsQuicApi
1818
{
1919
private static readonly Version s_minWindowsVersion = new Version(10, 0, 20145, 1000);
2020

21-
private static readonly Version s_minMsQuicVersion = new Version(2, 1);
21+
private static readonly Version s_minMsQuicVersion = new Version(2, 2, 2);
2222

2323
private static readonly delegate* unmanaged[Cdecl]<uint, QUIC_API_TABLE**, int> MsQuicOpenVersion;
2424
private static readonly delegate* unmanaged[Cdecl]<QUIC_API_TABLE*, void> MsQuicClose;

src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ internal enum QUIC_STREAM_OPEN_FLAGS
151151
NONE = 0x0000,
152152
UNIDIRECTIONAL = 0x0001,
153153
ZERO_RTT = 0x0002,
154+
DELAY_FC_UPDATES = 0x0004,
154155
}
155156

156157
[System.Flags]

src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ private unsafe int HandleEventPeerStreamStarted(ref PEER_STREAM_STARTED_DATA dat
515515
return QUIC_STATUS_SUCCESS;
516516
}
517517

518+
data.Flags |= QUIC_STREAM_OPEN_FLAGS.DELAY_FC_UPDATES;
518519
return QUIC_STATUS_SUCCESS;
519520
}
520521
private unsafe int HandleEventPeerCertificateReceived(ref PEER_CERTIFICATE_RECEIVED_DATA data)

src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,32 @@ ValueTask<QuicStream> OpenStreamAsync(QuicConnection connection) => unidirection
709709
await serverConnection.DisposeAsync();
710710
}
711711

712+
[Fact]
713+
public async Task OpenStreamAsync_BlocksUntilAvailable_PeerClosesWritingUnidirectional()
714+
{
715+
QuicListenerOptions listenerOptions = new QuicListenerOptions()
716+
{
717+
ListenEndPoint = new IPEndPoint(IPAddress.Loopback, 0),
718+
ApplicationProtocols = new List<SslApplicationProtocol>() { ApplicationProtocol },
719+
ConnectionOptionsCallback = (_, _, _) =>
720+
{
721+
var serverOptions = CreateQuicServerOptions();
722+
serverOptions.MaxInboundBidirectionalStreams = 1;
723+
serverOptions.MaxInboundUnidirectionalStreams = 1;
724+
return ValueTask.FromResult(serverOptions);
725+
}
726+
};
727+
(QuicConnection clientConnection, QuicConnection serverConnection) = await CreateConnectedQuicConnection(null, listenerOptions);
728+
729+
// Open one stream, second call should block
730+
await using var stream = await clientConnection.OpenOutboundStreamAsync(QuicStreamType.Unidirectional);
731+
await stream.WriteAsync(new byte[64*1024], completeWrites: true);
732+
await Assert.ThrowsAsync<TimeoutException>(() => clientConnection.OpenOutboundStreamAsync(QuicStreamType.Unidirectional).AsTask().WaitAsync(TimeSpan.FromSeconds(1)));
733+
734+
await clientConnection.DisposeAsync();
735+
await serverConnection.DisposeAsync();
736+
}
737+
712738
[Theory]
713739
[InlineData(false)]
714740
[InlineData(true)]
@@ -747,11 +773,24 @@ ValueTask<QuicStream> OpenStreamAsync(QuicConnection connection, CancellationTok
747773

748774
// Close the streams, the waitTask should finish as a result.
749775
await stream.DisposeAsync();
750-
QuicStream newStream = await serverConnection.AcceptInboundStreamAsync();
751-
await newStream.DisposeAsync();
776+
// Drain all server streams.
777+
while (true)
778+
{
779+
using var acceptCts = new CancellationTokenSource(TimeSpan.FromSeconds(0.5));
780+
try
781+
{
782+
QuicStream serverStream = await serverConnection.AcceptInboundStreamAsync(acceptCts.Token);
783+
await serverStream.DisposeAsync();
784+
}
785+
catch (OperationCanceledException)
786+
{
787+
// Token expired, no more streams in the server queue, exit the loop.
788+
break;
789+
}
790+
}
752791

753792
// next call should work as intended
754-
newStream = await OpenStreamAsync(clientConnection).AsTask().WaitAsync(TimeSpan.FromSeconds(10));
793+
var newStream = await OpenStreamAsync(clientConnection).AsTask().WaitAsync(TimeSpan.FromSeconds(10));
755794
await newStream.DisposeAsync();
756795

757796
await clientConnection.DisposeAsync();

0 commit comments

Comments
 (0)