Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
wj8400684 committed May 4, 2024
1 parent e7356eb commit 6d16273
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 234 deletions.
3 changes: 2 additions & 1 deletion src/SuperSocket.Connection/PipeConnectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ private async ValueTask HandleClosing()
{
try
{
await _pipeTask.ConfigureAwait(false);
if (_pipeTask != null)
await _pipeTask.ConfigureAwait(false);
}
catch (OperationCanceledException)
{
Expand Down
63 changes: 30 additions & 33 deletions src/SuperSocket.Quic.Connection/QuicPipeConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,44 @@

#pragma warning disable CA2252

namespace SuperSocket.Quic.Connection
namespace SuperSocket.Quic.Connection;

public class QuicPipeConnection : StreamPipeConnection
{
public class QuicPipeConnection : StreamPipeConnection
private readonly Stream _stream;

public QuicPipeConnection(Stream stream, EndPoint remoteEndPoint, ConnectionOptions options)
: this(stream, remoteEndPoint, null, options)
{
private readonly Stream _stream;
_stream = stream;
}

public QuicPipeConnection(Stream stream, EndPoint remoteEndPoint, ConnectionOptions options)
: this(stream, remoteEndPoint, null, options)
{
_stream = stream;
}
public QuicPipeConnection(Stream stream, EndPoint remoteEndPoint, EndPoint localEndPoint, ConnectionOptions options)
: base(stream, remoteEndPoint, localEndPoint, options)
{
_stream = stream;
}

public QuicPipeConnection(Stream stream, EndPoint remoteEndPoint, EndPoint localEndPoint,
ConnectionOptions options)
: base(stream, remoteEndPoint, localEndPoint, options)
{
_stream = stream;
}
protected override async Task StartInputPipeTask<TPackageInfo>(IObjectPipe<TPackageInfo> packagePipe, CancellationToken cancellationToken)
{
if (_stream is QuicPipeStream quicPipeStream)
await quicPipeStream.OpenStreamAsync(cancellationToken);

protected override async Task StartInputPipeTask<TPackageInfo>(IObjectPipe<TPackageInfo> packagePipe,
CancellationToken cancellationToken)
{
if (_stream is QuicPipeStream quicPipeStream)
await quicPipeStream.OpenStreamAsync(cancellationToken);

await base.StartInputPipeTask(packagePipe, cancellationToken);
}
await base.StartInputPipeTask(packagePipe, cancellationToken);
}

protected override bool IsIgnorableException(Exception e)
{
if (base.IsIgnorableException(e))
return true;

protected override bool IsIgnorableException(Exception e)
switch (e)
{
if (base.IsIgnorableException(e))
case QuicException:
case SocketException se when se.IsIgnorableSocketException():
return true;

switch (e)
{
case QuicException:
case SocketException se when se.IsIgnorableSocketException():
return true;
default:
return false;
}
default:
return false;
}
}
}
33 changes: 15 additions & 18 deletions src/SuperSocket.Quic/QuicConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
using System.Threading.Tasks;
using SuperSocket.Connection;
using SuperSocket.Quic.Connection;
using SuperSocket.Server.Abstractions;

#pragma warning disable CA2252
namespace SuperSocket.Quic
namespace SuperSocket.Quic;

internal class QuicConnectionFactory : IConnectionFactory
{
internal class QuicConnectionFactory : IConnectionFactory
private readonly ConnectionOptions _connectionOptions;

public QuicConnectionFactory(ConnectionOptions connectionOptions)
{
private readonly ListenOptions _listenOptions;
private readonly ConnectionOptions _connectionOptions;
public QuicConnectionFactory(ListenOptions listenOptions, ConnectionOptions connectionOptions)
{
_listenOptions = listenOptions;
_connectionOptions = connectionOptions;
}
_connectionOptions = connectionOptions;
}

public Task<IConnection> CreateConnection(object connection, CancellationToken cancellationToken)
{
var quicConnection = (QuicConnection)connection;
public Task<IConnection> CreateConnection(object connection, CancellationToken cancellationToken)
{
var quicConnection = (QuicConnection)connection;

var quicStream = new QuicPipeStream(quicConnection);
var quicStream = new QuicPipeStream(quicConnection);

var pipeConnection = new QuicPipeConnection(quicStream, quicConnection.RemoteEndPoint, quicConnection.LocalEndPoint, _connectionOptions);

return Task.FromResult<IConnection>(pipeConnection);
}
var pipeConnection = new QuicPipeConnection(quicStream, quicConnection.RemoteEndPoint, quicConnection.LocalEndPoint, _connectionOptions);

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This call site is reachable on all platforms. 'QuicConnection.LocalEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This call site is reachable on all platforms. 'QuicConnection.RemoteEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This call site is reachable on all platforms. 'QuicConnection.RemoteEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This call site is reachable on all platforms. 'QuicConnection.LocalEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This call site is reachable on all platforms. 'QuicConnection.LocalEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This call site is reachable on all platforms. 'QuicConnection.RemoteEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This call site is reachable on all platforms. 'QuicConnection.LocalEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This call site is reachable on all platforms. 'QuicConnection.RemoteEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This call site is reachable on all platforms. 'QuicConnection.RemoteEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 25 in src/SuperSocket.Quic/QuicConnectionFactory.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This call site is reachable on all platforms. 'QuicConnection.LocalEndPoint' is only supported on: 'linux', 'macOS/OSX', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

return Task.FromResult<IConnection>(pipeConnection);
}
}
11 changes: 5 additions & 6 deletions src/SuperSocket.Quic/QuicConnectionFactoryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
using SuperSocket.Server.Abstractions;
using SuperSocket.Server.Abstractions.Connections;

namespace SuperSocket.Quic
namespace SuperSocket.Quic;

internal class QuicConnectionFactoryBuilder : IConnectionFactoryBuilder
{
internal class QuicConnectionFactoryBuilder : IConnectionFactoryBuilder
public IConnectionFactory Build(ListenOptions listenOptions, ConnectionOptions connectionOptions)
{
public IConnectionFactory Build(ListenOptions listenOptions, ConnectionOptions connectionOptions)
{
return new QuicConnectionFactory(listenOptions, connectionOptions);
}
return new QuicConnectionFactory(connectionOptions);
}
}
Loading

0 comments on commit 6d16273

Please sign in to comment.