mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-08-16 08:16:09 +00:00
fix crash when double closing (#383)
This commit is contained in:
commit
5e13f9dd2d
@ -79,13 +79,17 @@ std::string TClient::GetCarPositionRaw(int Ident) {
|
|||||||
void TClient::Disconnect(std::string_view Reason) {
|
void TClient::Disconnect(std::string_view Reason) {
|
||||||
beammp_debugf("Disconnecting client {} for reason: {}", GetID(), Reason);
|
beammp_debugf("Disconnecting client {} for reason: {}", GetID(), Reason);
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
mSocket.shutdown(socket_base::shutdown_both, ec);
|
if (mSocket.is_open()) {
|
||||||
if (ec) {
|
mSocket.shutdown(socket_base::shutdown_both, ec);
|
||||||
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
if (ec) {
|
||||||
}
|
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
||||||
mSocket.close(ec);
|
}
|
||||||
if (ec) {
|
mSocket.close(ec);
|
||||||
beammp_debugf("Failed to close client socket: {}", ec.message());
|
if (ec) {
|
||||||
|
beammp_debugf("Failed to close client socket: {}", ec.message());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
beammp_debug("Socket is already closed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user