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:
Lion Kortlepel
2026-04-18 18:52:26 +02:00
parent 98fb12bbcc
commit 9ca12fc7a6
8 changed files with 260 additions and 229 deletions
+2 -2
View File
@@ -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;
}