mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-11 19:14:30 +00:00
Fix skip invalid socket (#477)
Removes continue in socket accept flow --- By creating this pull request, I understand that code that is AI generated or otherwise automatically generated may be rejected without further discussion. I declare that I fully understand all code I pushed into this PR, and wrote all this code myself and own the rights to this code.
This commit is contained in:
+6
-5
@@ -241,13 +241,14 @@ void TNetwork::TCPServerMain() {
|
|||||||
}
|
}
|
||||||
ip::tcp::endpoint ClientEp;
|
ip::tcp::endpoint ClientEp;
|
||||||
ip::tcp::socket ClientSocket = Acceptor.accept(ClientEp, ec);
|
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());
|
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();
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
beammp_errorf("Exception in accept routine: {}", e.what());
|
beammp_errorf("Exception in accept routine: {}", e.what());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user