Skip to content
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
4 changes: 2 additions & 2 deletions src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<!-- Source files -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
<Compile Include="System\Net\Quic\**\*.cs" Exclude="System\Net\Quic\*.Unsupported.cs"/>
<Compile Remove="System\Net\Quic\Implementations\Managed\**\*.cs" />
<!-- System.Net common -->
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs" Link="Common\DisableRuntimeMarshalling.cs" />
<Compile Include="$(CommonPath)System\Net\ArrayBuffer.cs" Link="Common\System\Net\ArrayBuffer.cs" />
Expand All @@ -41,7 +40,6 @@
<!-- Unsupported platforms -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == ''">
<Compile Include="System\Net\Quic\*.Unsupported.cs" />
<Compile Remove="System\Net\Quic\Implementations\Managed\**\*.cs" />
<!-- [ActiveIssue("https://github.com/dotnet/runtime/issues/71559")]: PNSE generator cannot handle required keyword, so excluding affected classes in ExcludeApiList.PNSE.txt and including real code for now. -->
<Compile Include="System\Net\Quic\QuicListenerOptions.cs" />
<Compile Include="System\Net\Quic\QuicConnectionOptions.cs" />
Expand Down Expand Up @@ -108,6 +106,7 @@
<Reference Include="Microsoft.Win32.Primitives" />
<Reference Include="System.Collections" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.Collections.Immutable" />
<Reference Include="System.Collections.NonGeneric" />
<Reference Include="System.Console" Condition="'$(Configuration)' == 'Debug'" />
<Reference Include="System.Diagnostics.Tracing" />
Expand All @@ -119,6 +118,7 @@
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Security.Cryptography" />
<Reference Include="System.Text.Json" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Channels" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace System.Net.Quic.Implementations.Managed
{
internal partial class ManagedQuicConnection
public partial class ManagedQuicConnection
{
/// <summary>
/// Returns true if the frame type requires receiver to sent acknowledgement before the maximum ack delay.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace System.Net.Quic.Implementations.Managed
{
internal sealed partial class ManagedQuicConnection
public sealed partial class ManagedQuicConnection
{
/// <summary>
/// Current value of the key phase bit for key update detection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace System.Net.Quic.Implementations.Managed
{
internal partial class ManagedQuicConnection
public partial class ManagedQuicConnection
{
/// <summary>
/// Marks the connection data sent in the packet as acknowledged.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace System.Net.Quic.Implementations.Managed
{
internal partial class ManagedQuicConnection
public partial class ManagedQuicConnection
{
private struct ConnectionFlowControlLimits
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace System.Net.Quic.Implementations.Managed
{
internal sealed partial class ManagedQuicConnection : QuicConnectionProvider
public sealed partial class ManagedQuicConnection : QuicConnectionProvider
{
// This limit should ensure that if we can fit at least an ack frame into the packet,
private const int RequiredAllowanceForSending = 2 * ConnectionId.MaximumLength + 40;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@

namespace System.Net.Quic.Implementations.Managed
{
internal sealed class ManagedQuicListener : QuicListenerProvider
public sealed class ManagedQuicListener : IAsyncDisposable
{
public static bool IsSupported => true;
public static ValueTask<ManagedQuicListener> ListenAsync(QuicListenerOptions options, CancellationToken cancellationToken = default)
{
return ValueTask.FromResult(new ManagedQuicListener(options));
}

private bool _disposed;

private readonly ChannelReader<ManagedQuicConnection> _acceptQueue;
private readonly QuicServerSocketContext _socketContext;

public ManagedQuicListener(QuicListenerOptions options, TlsFactory tlsFactory)
private ManagedQuicListener(QuicListenerOptions options)
{
var listenEndPoint = options.ListenEndPoint ?? new IPEndPoint(IPAddress.Any, 0);

Expand All @@ -30,47 +36,26 @@ public ManagedQuicListener(QuicListenerOptions options, TlsFactory tlsFactory)
});

_acceptQueue = channel.Reader;
_socketContext = new QuicServerSocketContext(listenEndPoint, options, channel.Writer, tlsFactory);
Start();
}

internal override IPEndPoint ListenEndPoint
{
get
{
ThrowIfDisposed();
return _socketContext.LocalEndPoint;
}
_socketContext = new QuicServerSocketContext(listenEndPoint, options, channel.Writer, OpenSslTlsFactory.Instance);
_socketContext.Start();
}

internal override async ValueTask<QuicConnectionProvider> AcceptConnectionAsync(
CancellationToken cancellationToken = default)
{
ThrowIfDisposed();
// TODO-RZ: make this non-async when the cast is no longer needed
return await _acceptQueue.ReadAsync(cancellationToken).ConfigureAwait(false);
}
public IPEndPoint ListenEndPoint => _socketContext.LocalEndPoint;

private void Start()
public ValueTask<ManagedQuicConnection> AcceptConnectionAsync(CancellationToken cancellationToken = default)
{
ThrowIfDisposed();
ObjectDisposedException.ThrowIf(_disposed, this);

_socketContext.Start();
return _acceptQueue.ReadAsync(cancellationToken);
}

public override void Dispose()
public ValueTask DisposeAsync()
{
if (_disposed) return;
_socketContext.StopOrOrphan();

_disposed = true;
}

private void ThrowIfDisposed()
{
if (_disposed)
{
throw new ObjectDisposedException(nameof(ManagedQuicListener));
}
_socketContext.StopOrOrphan();
}
}
}