add more warning prints on unexpected cases

This commit is contained in:
Lion Kortlepel 2022-10-28 17:51:02 +02:00
parent 99f41c28cb
commit f9251ff92c
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -526,7 +526,7 @@ void TNetwork::OnDisconnect(const std::weak_ptr<TClient>& ClientPtr) {
try {
LockedClientPtr = ClientPtr.lock();
} catch (const std::exception&) {
// do nothing ig
beammp_warn("Client expired in OnDisconnect, this is unexpected");
return;
}
beammp_assert(LockedClientPtr != nullptr);
@ -866,11 +866,12 @@ void TNetwork::SendToAll(TClient* c, const std::vector<uint8_t>& Data, bool Self
bool ret = true;
mServer.ForEachClient([&](std::weak_ptr<TClient> ClientPtr) -> bool {
std::shared_ptr<TClient> Client;
{
try {
ReadLock Lock(mServer.GetClientMutex());
if (!ClientPtr.expired()) {
Client = ClientPtr.lock();
} else
} catch (const std::exception&) {
// continue
beammp_warn("Client expired, shouldn't happen - if a client disconnected recently, you can ignore this");
return true;
}
if (Self || Client.get() != c) {