Skip to content

Commit

Permalink
Merge pull request dotnet#90173 from vseanreesermsft/internal-merge-7…
Browse files Browse the repository at this point in the history
….0-2023-08-08-1042

Merging internal commits for release/7.0
  • Loading branch information
carlossanlop authored and ManickaP committed Aug 9, 2023
1 parent 88633ae commit 913e3dd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
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
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

0 comments on commit 913e3dd

Please sign in to comment.