FtpServer
FtpServer copied to clipboard
Remove custom cancellation token handling code, rely on Stream.ReadAsync to handle it instead
Fixes #131
I've tried tracing this code back in git history to figure out why this override exists. Previously it had a comment:
We ensure that this service can be closed ASAP with the help of a Task.Delay.
Does Stream.ReadAsync
take meaningfully longer to cancel than using a TaskCompletionSource
?.
If there is a reason it is this way, we can probably keep the behaviour and observe the result so that the we don't end up with an UnobservedTaskException later, it'll be a bit clunky though.
It might've been a problem in an older version of .NET (Core), that the stream would only be cancelled when new data arrives or some timeout occurs.
Is this something we need to support or test? If you can let me know what needs manual testing I can hopefully do it.
I thought that I read in an article (MS blog post), that they fixed it in .NET Core 3.1, but I might be misremembering it. You can read more about it here:
https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7/#file-i-o