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

[QUIC] Merge 7.0 fix #90228

Merged
merged 2 commits into from
Aug 14, 2023
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
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-rc.1.23381.1</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.23401.4</runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ internal enum QUIC_STREAM_OPEN_FLAGS
NONE = 0x0000,
UNIDIRECTIONAL = 0x0001,
ZERO_RTT = 0x0002,
DELAY_FC_UPDATES = 0x0004,
}

[System.Flags]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ private unsafe int HandleEventPeerStreamStarted(ref PEER_STREAM_STARTED_DATA dat
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)
Expand Down
45 changes: 42 additions & 3 deletions src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,32 @@ ValueTask<QuicStream> OpenStreamAsync(QuicConnection connection) => unidirection
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)]
Expand Down Expand Up @@ -747,11 +773,24 @@ ValueTask<QuicStream> OpenStreamAsync(QuicConnection connection, CancellationTok

// 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();
Expand Down
Loading