summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-05-10 09:55:19 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-05-10 09:55:19 -0400
commit271bc05b91772e5aedd834db116734b34f0108a1 (patch)
treeabb017c930974741bc8bf6f8b352c4124fc03ef6
parent5060ccb1530ab576458aeff0d0b2b5dd24bc5880 (diff)
Fix latent access violation in ~LLEventPump() if LLEventPumps gone.
Instead of making LLEventPumps an LLHandleProvider, and storing an LLHandle<LLEventPumps> in each LLEventPump instance, just make ~LLEventPump() query LLEventPumps::instanceExists() before calling instance().
-rw-r--r--indra/llcommon/llevents.cpp8
-rw-r--r--indra/llcommon/llevents.h16
2 files changed, 4 insertions, 20 deletions
diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp
index e10e555f8b..5a6e13cb7d 100644
--- a/indra/llcommon/llevents.cpp
+++ b/indra/llcommon/llevents.cpp
@@ -359,8 +359,7 @@ const std::string LLEventPump::ANONYMOUS = std::string();
LLEventPump::LLEventPump(const std::string& name, bool tweak):
// Register every new instance with LLEventPumps
- mRegistry(LLEventPumps::instance().getHandle()),
- mName(mRegistry.get()->registerNew(*this, name, tweak)),
+ mName(LLEventPumps::instance().registerNew(*this, name, tweak)),
mSignal(std::make_shared<LLStandardSignal>()),
mEnabled(true)
{}
@@ -373,10 +372,9 @@ LLEventPump::~LLEventPump()
{
// Unregister this doomed instance from LLEventPumps -- but only if
// LLEventPumps is still around!
- LLEventPumps* registry = mRegistry.get();
- if (registry)
+ if (LLEventPumps::instanceExists())
{
- registry->unregister(*this);
+ LLEventPumps::instance().unregister(*this);
}
}
diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index 1fc0f23ecd..15d1d5035c 100644
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -53,7 +53,6 @@
#include "llsingleton.h"
#include "lldependencies.h"
#include "llexception.h"
-#include "llhandle.h"
// hack for testing
#ifndef testable
@@ -213,15 +212,7 @@ class LLEventPump;
* LLEventPumps is a Singleton manager through which one typically accesses
* this subsystem.
*/
-// LLEventPumps isa LLHandleProvider only for (hopefully rare) long-lived
-// class objects that must refer to this class late in their lifespan, say in
-// the destructor. Specifically, the case that matters is a possible reference
-// after LLEventPumps::deleteSingleton(). (Lingering LLEventPump instances are
-// capable of this.) In that case, instead of calling LLEventPumps::instance()
-// again -- resurrecting the deleted LLSingleton -- store an
-// LLHandle<LLEventPumps> and test it before use.
-class LL_COMMON_API LLEventPumps: public LLSingleton<LLEventPumps>,
- public LLHandleProvider<LLEventPumps>
+class LL_COMMON_API LLEventPumps: public LLSingleton<LLEventPumps>
{
LLSINGLETON(LLEventPumps);
public:
@@ -582,12 +573,7 @@ private:
virtual void clear();
virtual void reset();
-
-
private:
- // must precede mName; see LLEventPump::LLEventPump()
- LLHandle<LLEventPumps> mRegistry;
-
std::string mName;
LLMutex mConnectionListMutex;