fix crash when double closing

This commit is contained in:
Lion Kortlepel 2024-11-01 15:07:54 +01:00
parent e3416804e4
commit 576d765557
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -79,6 +79,7 @@ std::string TClient::GetCarPositionRaw(int Ident) {
void TClient::Disconnect(std::string_view Reason) {
beammp_debugf("Disconnecting client {} for reason: {}", GetID(), Reason);
boost::system::error_code ec;
if (mSocket.is_open()) {
mSocket.shutdown(socket_base::shutdown_both, ec);
if (ec) {
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
@ -87,6 +88,9 @@ void TClient::Disconnect(std::string_view Reason) {
if (ec) {
beammp_debugf("Failed to close client socket: {}", ec.message());
}
} else {
beammp_debug("Socket is already closed.");
}
}
void TClient::SetCarPosition(int Ident, const std::string& Data) {