From cf1f8e7385b44330da21bfe656d5aea76d9f2f38 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 16 Mar 2021 20:33:21 -0400 Subject: [PATCH] Core/RemoteAccess: Fixes high cpu when closing the telnet client without using the exit command. --- Source/Game/Networking/RASocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Game/Networking/RASocket.cs b/Source/Game/Networking/RASocket.cs index 65c53406f..3d7dfe1c9 100644 --- a/Source/Game/Networking/RASocket.cs +++ b/Source/Game/Networking/RASocket.cs @@ -127,7 +127,10 @@ namespace Game.Networking do { int bytes = _socket.Receive(_receiveBuffer); - str = String.Concat(str, Encoding.UTF8.GetString(_receiveBuffer, 0, bytes)); + if (bytes == 0) + return ""; + + str = string.Concat(str, Encoding.UTF8.GetString(_receiveBuffer, 0, bytes)); } while (!str.Contains("\n")); @@ -195,7 +198,7 @@ namespace Game.Networking bool ProcessCommand(string command) { if (command.Length == 0) - return true; + return false; Log.outInfo(LogFilter.CommandsRA, $"Received command: {command}");