From 0003f9566c70359cb3acd6dff9cfeb0ff4607aaf Mon Sep 17 00:00:00 2001 From: "starlkytminecraft@gmail.com" Date: Mon, 22 Jan 2024 01:27:23 +0300 Subject: [PATCH] Fixes #418 --- Obsidian/Server.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Obsidian/Server.cs b/Obsidian/Server.cs index e3b277ac6..ef6379598 100644 --- a/Obsidian/Server.cs +++ b/Obsidian/Server.cs @@ -67,6 +67,7 @@ public static string VERSION private readonly ILogger _logger; private IConnectionListener? _tcpListener; + private bool _isFullyInitialized; public ProtocolVersion Protocol => DefaultProtocol; @@ -289,6 +290,7 @@ public async Task RunAsync() continue; _logger.LogInformation("Listening for new clients..."); + _isFullyInitialized = true; try { @@ -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) {