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