mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-07-13 10:13:42 +00:00
fix std::weak_ptr locking and expiry checks
You're supposed to .lock() instead of TOCTOU checking, of course. Not sure what I was thinking when I built that. .lock() returns a default constructed std::shared_ptr on error, which is `false` via `operator bool`.
This commit is contained in:
+2
-2
@@ -55,8 +55,8 @@ void TPPSMonitor::operator()() {
|
||||
std::shared_ptr<TClient> c;
|
||||
{
|
||||
ReadLock Lock(mServer.GetClientMutex());
|
||||
if (!ClientPtr.expired()) {
|
||||
c = ClientPtr.lock();
|
||||
if (auto Locked = ClientPtr.lock()) {
|
||||
c = std::move(Locked);
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user