summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llsingleton.cpp46
-rw-r--r--indra/llcommon/llsingleton.h30
-rw-r--r--indra/newview/llappviewer.cpp7
-rw-r--r--indra/newview/llappviewerwin32.cpp7
-rw-r--r--indra/newview/llwindebug.cpp4
-rw-r--r--indra/newview/llwindebug.h4
6 files changed, 16 insertions, 82 deletions
diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp
index 9025e53bb2..18e1b96a5f 100644
--- a/indra/llcommon/llsingleton.cpp
+++ b/indra/llcommon/llsingleton.cpp
@@ -369,62 +369,20 @@ void LLSingletonBase::deleteAll()
}
}
-/*------------------------ Final cleanup management ------------------------*/
-class LLSingletonBase::MasterRefcount
-{
-public:
- // store a POD int so it will be statically initialized to 0
- int refcount;
-};
-static LLSingletonBase::MasterRefcount sMasterRefcount;
-
-LLSingletonBase::ref_ptr_t LLSingletonBase::get_master_refcount()
-{
- // Calling this method constructs a new ref_ptr_t, which implicitly calls
- // intrusive_ptr_add_ref(MasterRefcount*).
- return &sMasterRefcount;
-}
-
-void intrusive_ptr_add_ref(LLSingletonBase::MasterRefcount* mrc)
-{
- // Count outstanding SingletonLifetimeManager instances.
- ++mrc->refcount;
-}
-
-void intrusive_ptr_release(LLSingletonBase::MasterRefcount* mrc)
-{
- // Notice when each SingletonLifetimeManager instance is destroyed.
- if (! --mrc->refcount)
- {
- // The last instance was destroyed. Time to kill any remaining
- // LLSingletons -- but in dependency order.
- LLSingletonBase::deleteAll();
- }
-}
-
/*---------------------------- Logging helpers -----------------------------*/
namespace {
bool oktolog()
{
// See comments in log() below.
- return sMasterRefcount.refcount && LLError::is_available();
+ return LLError::is_available();
}
void log(LLError::ELevel level,
const char* p1, const char* p2, const char* p3, const char* p4)
{
- // Check whether we're in the implicit final LLSingletonBase::deleteAll()
- // call. We've carefully arranged for deleteAll() to be called when the
- // last SingletonLifetimeManager instance is destroyed -- in other words,
- // when the last translation unit containing an LLSingleton instance
- // cleans up static data. That could happen after std::cerr is destroyed!
// The is_available() test below ensures that we'll stop logging once
// LLError has been cleaned up. If we had a similar portable test for
- // std::cerr, this would be a good place to use it. As we do not, just
- // don't log anything during implicit final deleteAll(). Detect that by
- // the master refcount having gone to zero.
- if (sMasterRefcount.refcount == 0)
- return;
+ // std::cerr, this would be a good place to use it.
// Check LLError::is_available() because some of LLError's infrastructure
// is itself an LLSingleton. If that LLSingleton has not yet been
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 0d4a1f34f8..859e271e26 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -27,7 +27,6 @@
#include <boost/noncopyable.hpp>
#include <boost/unordered_set.hpp>
-#include <boost/intrusive_ptr.hpp>
#include <list>
#include <vector>
#include <typeinfo>
@@ -36,8 +35,6 @@ class LLSingletonBase: private boost::noncopyable
{
public:
class MasterList;
- class MasterRefcount;
- typedef boost::intrusive_ptr<MasterRefcount> ref_ptr_t;
private:
// All existing LLSingleton instances are tracked in this master list.
@@ -119,9 +116,6 @@ protected:
const char* p3="", const char* p4="");
static std::string demangle(const char* mangled);
- // obtain canonical ref_ptr_t
- static ref_ptr_t get_master_refcount();
-
// Default methods in case subclass doesn't declare them.
virtual void initSingleton() {}
virtual void cleanupSingleton() {}
@@ -175,10 +169,6 @@ public:
static void deleteAll();
};
-// support ref_ptr_t
-void intrusive_ptr_add_ref(LLSingletonBase::MasterRefcount*);
-void intrusive_ptr_release(LLSingletonBase::MasterRefcount*);
-
// Most of the time, we want LLSingleton_manage_master() to forward its
// methods to real LLSingletonBase methods.
template <class T>
@@ -298,8 +288,7 @@ private:
// stores pointer to singleton instance
struct SingletonLifetimeManager
{
- SingletonLifetimeManager():
- mMasterRefcount(LLSingletonBase::get_master_refcount())
+ SingletonLifetimeManager()
{
construct();
}
@@ -317,17 +306,14 @@ private:
// of static-object destruction, mean that we DO NOT WANT this
// destructor to delete this LLSingleton. This destructor will run
// without regard to any other LLSingleton whose cleanup might
- // depend on its existence. What we really want is to count the
- // runtime's attempts to cleanup LLSingleton static data -- and on
- // the very last one, call LLSingletonBase::deleteAll(). That
- // method will properly honor cross-LLSingleton dependencies. This
- // is why we store an intrusive_ptr to a MasterRefcount: our
- // ref_ptr_t member counts SingletonLifetimeManager instances.
- // Once the runtime destroys the last of these, THEN we can delete
- // every remaining LLSingleton.
+ // depend on its existence. If you want to clean up LLSingletons,
+ // call LLSingletonBase::deleteAll() sometime before static-object
+ // destruction begins. That method will properly honor cross-
+ // LLSingleton dependencies. Otherwise we simply leak LLSingleton
+ // instances at shutdown. Since the whole process is terminating
+ // anyway, that's not necessarily a bad thing; it depends on what
+ // resources your LLSingleton instances are managing.
}
-
- LLSingletonBase::ref_ptr_t mMasterRefcount;
};
protected:
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 850f7b1c31..a26ee2204b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2114,13 +2114,6 @@ bool LLAppViewer::cleanup()
// This calls every remaining LLSingleton's deleteSingleton() method.
// No class destructor should perform any cleanup that might take
// significant realtime, or throw an exception.
- // LLSingleton machinery includes a last-gasp implicit deleteAll() call,
- // so this explicit call shouldn't strictly be necessary. However, by the
- // time the runtime engages that implicit call, it may already have
- // destroyed things like std::cerr -- so the implicit deleteAll() refrains
- // from logging anything. Since both cleanupAll() and deleteAll() call
- // their respective cleanup methods in computed dependency order, it's
- // probably useful to be able to log that order.
LLSingletonBase::deleteAll();
removeDumpDir();
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 5107030476..d6039f6d7f 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -502,7 +502,8 @@ bool LLAppViewerWin32::init()
disableWinErrorReporting();
#ifndef LL_RELEASE_FOR_DOWNLOAD
- LLWinDebug::instance().init();
+ // Merely requesting the LLSingleton instance initializes it.
+ LLWinDebug::instance();
#endif
#if LL_WINDOWS
@@ -526,10 +527,6 @@ bool LLAppViewerWin32::cleanup()
gDXHardware.cleanup();
-#ifndef LL_RELEASE_FOR_DOWNLOAD
- LLWinDebug::instance().cleanup();
-#endif
-
if (mIsConsoleAllocated)
{
FreeConsole();
diff --git a/indra/newview/llwindebug.cpp b/indra/newview/llwindebug.cpp
index eff70ca0b2..92c80ce534 100644
--- a/indra/newview/llwindebug.cpp
+++ b/indra/newview/llwindebug.cpp
@@ -90,7 +90,7 @@ LONG NTAPI vectoredHandler(PEXCEPTION_POINTERS exception_infop)
}
// static
-void LLWinDebug::init()
+void LLWinDebug::initSingleton()
{
static bool s_first_run = true;
// Load the dbghelp dll now, instead of waiting for the crash.
@@ -135,7 +135,7 @@ void LLWinDebug::init()
}
}
-void LLWinDebug::cleanup ()
+void LLWinDebug::cleanupSingleton()
{
gEmergencyMemoryReserve.release();
}
diff --git a/indra/newview/llwindebug.h b/indra/newview/llwindebug.h
index 90882cf04a..7e5818ba1c 100644
--- a/indra/newview/llwindebug.h
+++ b/indra/newview/llwindebug.h
@@ -36,9 +36,9 @@ class LLWinDebug:
{
LLSINGLETON_EMPTY_CTOR(LLWinDebug);
public:
- static void init();
+ void initSingleton();
static void generateMinidump(struct _EXCEPTION_POINTERS *pExceptionInfo = NULL);
- static void cleanup();
+ void cleanupSingleton();
private:
static void writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMATION *ExInfop, const std::string& filename);
};