Fix for the function to save to the database.

This commit is contained in:
Kei-Luna
2026-04-30 15:46:00 +09:00
parent 4bd66621bf
commit bcc5716f97

View File

@@ -74,12 +74,20 @@ public sealed class ProxyServer(
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested) catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{ {
} }
catch (SocketException) when (stoppingToken.IsCancellationRequested)
{
}
catch (ObjectDisposedException) when (stoppingToken.IsCancellationRequested)
{
}
} }
public override Task StopAsync(CancellationToken cancellationToken) public override async Task StopAsync(CancellationToken cancellationToken)
{ {
// Cancel the BackgroundService token first so shutdown exceptions are treated as expected.
var stopTask = base.StopAsync(cancellationToken);
_listener?.Stop(); _listener?.Stop();
return base.StopAsync(cancellationToken); await stopTask;
} }
private async Task HandleClientAsync(TcpClient client, CancellationToken cancellationToken) private async Task HandleClientAsync(TcpClient client, CancellationToken cancellationToken)