Skip to content

Commit

Permalink
Fixes #418
Browse files Browse the repository at this point in the history
  • Loading branch information
TheVeryStarlk committed Jan 21, 2024
1 parent e08e0ea commit 0003f95
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Obsidian/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static string VERSION
private readonly ILogger _logger;

private IConnectionListener? _tcpListener;
private bool _isFullyInitialized;

public ProtocolVersion Protocol => DefaultProtocol;

Expand Down Expand Up @@ -289,6 +290,7 @@ public async Task RunAsync()
continue;

_logger.LogInformation("Listening for new clients...");
_isFullyInitialized = true;

try
{
Expand Down Expand Up @@ -331,8 +333,17 @@ private async Task AcceptClientsAsync()
// No longer accepting clients.
break;
}

connection = acceptedConnection;

if (!_isFullyInitialized)
{
connection.Abort();
await connection.DisposeAsync();

_logger.LogDebug("Server has not been fully initialized. Aborted the connection");
continue;
}

}
catch (OperationCanceledException)
{
Expand Down

0 comments on commit 0003f95

Please sign in to comment.