mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-08-16 16:26:26 +00:00
fix crash when double closing
This commit is contained in:
parent
e3416804e4
commit
576d765557
@ -79,6 +79,7 @@ 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;
|
||||||
|
if (mSocket.is_open()) {
|
||||||
mSocket.shutdown(socket_base::shutdown_both, ec);
|
mSocket.shutdown(socket_base::shutdown_both, ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
||||||
@ -87,6 +88,9 @@ void TClient::Disconnect(std::string_view Reason) {
|
|||||||
if (ec) {
|
if (ec) {
|
||||||
beammp_debugf("Failed to close client socket: {}", ec.message());
|
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) {
|
void TClient::SetCarPosition(int Ident, const std::string& Data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user