From b4b262196b1c574b4374f936d4225cf90902a83f Mon Sep 17 00:00:00 2001 From: SaltySnail Date: Sat, 28 Mar 2026 16:15:42 +0100 Subject: [PATCH 1/2] Revert "Skip invalid socket when accept() fails" This reverts commit 83afafc0c3daa92857254e283a27192948c68d59. --- src/TNetwork.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index 02fb55b..6e5f51f 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -243,11 +243,10 @@ void TNetwork::TCPServerMain() { ip::tcp::socket ClientSocket = Acceptor.accept(ClientEp, ec); if (ec) { beammp_errorf("Failed to accept() new client: {}", ec.message()); - continue; } TConnection Conn { std::move(ClientSocket), ClientEp }; std::thread ID(&TNetwork::Identify, this, std::move(Conn)); - ID.detach(); + ID.detach(); // TODO: Add to a queue and attempt to join periodically } catch (const std::exception& e) { beammp_errorf("Exception in accept routine: {}", e.what()); } From 75e9c52ce850a6e919cc39274ac24d307c2ef151 Mon Sep 17 00:00:00 2001 From: SaltySnail Date: Sat, 28 Mar 2026 16:23:29 +0100 Subject: [PATCH 2/2] Rewrite accept code to not use continue --- src/TNetwork.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index 6e5f51f..9c88dea 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -241,12 +241,14 @@ void TNetwork::TCPServerMain() { } ip::tcp::endpoint ClientEp; ip::tcp::socket ClientSocket = Acceptor.accept(ClientEp, ec); - if (ec) { + if (!ec) { + TConnection Conn { std::move(ClientSocket), ClientEp }; + std::thread ID(&TNetwork::Identify, this, std::move(Conn)); + ID.detach(); // TODO: Add to a queue and attempt to join periodically + } + else { beammp_errorf("Failed to accept() new client: {}", ec.message()); } - TConnection Conn { std::move(ClientSocket), ClientEp }; - std::thread ID(&TNetwork::Identify, this, std::move(Conn)); - ID.detach(); // TODO: Add to a queue and attempt to join periodically } catch (const std::exception& e) { beammp_errorf("Exception in accept routine: {}", e.what()); }