Skip to content

Commit 3a1b1fb

Browse files
committed
Fix(?) for issue #82
1 parent ae9c394 commit 3a1b1fb

9 files changed

Lines changed: 10 additions & 40 deletions

File tree

FubarDev.FtpServer.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1616
PackageLibrary.props = PackageLibrary.props
1717
README.md = README.md
1818
stylecop.json = stylecop.json
19+
DotNetSdkMono.props = DotNetSdkMono.props
1920
EndProjectSection
2021
EndProject
2122
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FubarDev.FtpServer.FileSystem.DotNet", "src\FubarDev.FtpServer.FileSystem.DotNet\FubarDev.FtpServer.FileSystem.DotNet.csproj", "{9A83C6F5-378B-48B3-B32A-151DB90B390C}"

src/FubarDev.FtpServer/ConnectionHandlers/IFtpConnectionAdapter.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,5 @@ public interface IFtpConnectionAdapter : IFtpService
2424
/// Gets the pausable receiver for this connection adapter.
2525
/// </summary>
2626
IPausableFtpService Receiver { get; }
27-
28-
/// <summary>
29-
/// Writes all pending data to the output.
30-
/// </summary>
31-
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
32-
/// <returns>The task.</returns>
33-
Task FlushAsync(CancellationToken cancellationToken);
3427
}
3528
}

src/FubarDev.FtpServer/ConnectionHandlers/PassThroughConnectionAdapter.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ public PassThroughConnectionAdapter(
5252
/// <inheritdoc />
5353
public IPausableFtpService Receiver => _receiverService;
5454

55-
/// <inheritdoc />
56-
public async Task FlushAsync(CancellationToken cancellationToken)
57-
{
58-
await _transmitService.PauseAsync(cancellationToken);
59-
await _transmitService.ContinueAsync(cancellationToken);
60-
}
61-
6255
/// <inheritdoc />
6356
public Task StartAsync(CancellationToken cancellationToken)
6457
{

src/FubarDev.FtpServer/ConnectionHandlers/SecureConnectionAdapter.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ public SecureConnectionAdapter(
5959
/// <inheritdoc />
6060
public IPausableFtpService Receiver => _activeCommunicationService.Receiver;
6161

62-
/// <inheritdoc />
63-
public Task FlushAsync(CancellationToken cancellationToken)
64-
{
65-
return _activeCommunicationService.FlushAsync(cancellationToken);
66-
}
67-
6862
/// <inheritdoc />
6963
public async Task ResetAsync(CancellationToken cancellationToken)
7064
{

src/FubarDev.FtpServer/ConnectionHandlers/SslStreamConnectionAdapter.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ public IPausableFtpService Receiver
5757
=> _info?.ReceiverService
5858
?? throw new InvalidOperationException("Receiver can only be accessed when the connection service was started.");
5959

60-
/// <inheritdoc />
61-
public async Task FlushAsync(CancellationToken cancellationToken)
62-
{
63-
if (_info != null)
64-
{
65-
await _info.TransmitterService.PauseAsync(cancellationToken);
66-
await _info.TransmitterService.ContinueAsync(cancellationToken);
67-
}
68-
}
69-
7060
/// <inheritdoc />
7161
public async Task StartAsync(CancellationToken cancellationToken)
7262
{

src/FubarDev.FtpServer/Networking/PassThroughService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
7676
await _writer.WriteAsync(memory, CancellationToken.None)
7777
.ConfigureAwait(false);
7878

79-
await _writer.FlushAsync(CancellationToken.None)
80-
.ConfigureAwait(false);
81-
8279
if (readResult.IsCanceled || readResult.IsCompleted)
8380
{
8481
break;
@@ -87,6 +84,9 @@ await _writer.FlushAsync(CancellationToken.None)
8784

8885
_reader.AdvanceTo(buffer.End);
8986

87+
await _writer.FlushAsync(CancellationToken.None)
88+
.ConfigureAwait(false);
89+
9090
if (readResult.IsCanceled || readResult.IsCompleted)
9191
{
9292
Logger?.LogTrace("Cancelled={cancelled} or completed={completed}", readResult.IsCanceled, readResult.IsCompleted);

src/FubarDev.FtpServer/ServerCommandHandlers/CloseConnectionServerCommandHandler.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77

8+
using FubarDev.FtpServer.Features;
89
using FubarDev.FtpServer.ServerCommands;
910

1011
using Microsoft.Extensions.DependencyInjection;
@@ -29,15 +30,16 @@ public CloseConnectionServerCommandHandler(
2930
}
3031

3132
/// <inheritdoc />
32-
public Task ExecuteAsync(CloseConnectionServerCommand command, CancellationToken cancellationToken)
33+
public async Task ExecuteAsync(CloseConnectionServerCommand command, CancellationToken cancellationToken)
3334
{
3435
var connection = _connectionAccessor.FtpConnection;
3536

37+
var networkStreamFeature = connection.Features.Get<INetworkStreamFeature>();
38+
await networkStreamFeature.SecureConnectionAdapter.StopAsync(cancellationToken);
39+
3640
// Just abort the connection. This should avoid problems with an ObjectDisposedException.
3741
// The "StopAsync" will be called in CommandChannelDispatcherAsync.
3842
((FtpConnection)connection).Abort();
39-
40-
return Task.CompletedTask;
4143
}
4244
}
4345
}

src/FubarDev.FtpServer/ServerCommandHandlers/SendResponseServerCommandHandler.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ await WriteResponseAsync(connection, nextResponse, cancellationToken)
9494

9595
await writer.FlushAsync(cancellationToken)
9696
.ConfigureAwait(false);
97-
98-
var connectionAdapter = networkStreamFeature.SecureConnectionAdapter;
99-
await connectionAdapter.FlushAsync(cancellationToken);
10097
}
10198
}
10299
}

test/FubarDev.FtpServer.Tests/Issues/Issue82ProtocolViolation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public Issue82ProtocolViolation(ITestOutputHelper testOutputHelper)
2323
[Fact]
2424
public async Task TestParallelRequests()
2525
{
26-
const int maxTasks = 20;
26+
const int maxTasks = 100;
2727
var tasks = new List<Task>();
2828
for (var i = 0; i != maxTasks; i++)
2929
{

0 commit comments

Comments
 (0)